From 08e8d76bdb84d04697ab79873039f97be302bb7f Mon Sep 17 00:00:00 2001 From: Nate Buttke Date: Sat, 5 Nov 2022 23:01:51 -0700 Subject: write plan more succinctly and better --- plan | 58 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/plan b/plan index 72c64b5..c880497 100755 --- a/plan +++ b/plan @@ -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 -- cgit v1.2.3