diff options
author | Nate Buttke <nate-web@riseup.net> | 2022-11-05 23:01:51 -0700 |
---|---|---|
committer | Nate Buttke <nate-web@riseup.net> | 2022-11-05 23:01:51 -0700 |
commit | 08e8d76bdb84d04697ab79873039f97be302bb7f (patch) | |
tree | 07b63f047c6a00a1d34ece6d58418f1cba252812 | |
parent | 414a756c045b2d2f19efcd3138c318fa1eb9e2f2 (diff) |
write plan more succinctly and better
-rwxr-xr-x | plan | 58 |
1 files changed, 28 insertions, 30 deletions
@@ -3,29 +3,45 @@ if [ "$1" == next ]; then - date=$(date --date="Next Mon" +%b%d | tr A-Z a-z) - lastMonday=$(date --date="Last Mon" +%b%d | tr A-Z a-z) - lastPath="/home/n8/dox/plan/weekly/$lastMonday/$lastMonday" - echo "$lastPath" printf "Planning for next week.\n" +fi -else - if date +%a | grep -q Mon ; then - date=$(date --date="This Mon" +%b%d | tr A-Z a-z) # today is monday +if date +%a | grep -q Mon ; then # today is monday + date=$(date --date="This Mon" +%b%d | tr A-Z a-z) printf "today is monday.\n" - else - date=$(date --date="Last Mon" +%b%d | tr A-Z a-z) # today is NOT monday + if [ "$1" == next ]; then + date=$(date --date="$date + 1 week" +%b%d | tr A-Z a-z) + fi +else # today is NOT monday + date=$(date --date="Last Mon" +%b%d | tr A-Z a-z) printf "today is NOT monday.\n" - fi + if [ "$1" == next ]; then + date=$(date --date="$date + 1 week" +%b%d | tr A-Z a-z) + fi fi +echo $date +echo $date + filepath="/home/n8/dox/plan/weekly/$date/$date" directory="/home/n8/dox/plan/weekly/$date/" template="/home/n8/dox/plan/weekly/template" +openPlan(){ + # Create file if it is not there + if [ ! -f $filepath.md ]; then + mkdir -p $directory + cp $template.md $filepath.md + fi + if [[ $(tty) =~ "not a tty" ]]; then + foot -e nvim $filepath.md + else + nvim $filepath.md + fi +} + if [ -n "$1" ]; then - if [ "$1" == f ]; then if [ -f $filepath.md ]; then @@ -33,23 +49,5 @@ then firefox $filepath.html fi fi - - if [ "$1" == next ]; then - if [ ! -f $filepath.md ]; then - mkdir -p $directory - cp $template.md $filepath.md - fi - foot -e nvim $filepath.md - fi - -else - if [ ! -f $filepath.md ]; then - mkdir -p $directory - cp $template.md $filepath.md - fi - if [[ $(tty) =~ "not a tty" ]]; then - foot -e nvim $filepath.md - else - nvim $filepath.md - fi fi +openPlan |