summaryrefslogtreecommitdiff
path: root/plan
blob: 72c64b539f59f12c78d31f9860879c43e8beecbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#TODO: pandoc --pdf-engine=xelatex jan24.md -o test.pdf


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"

else
  if date +%a | grep -q Mon ; then
    date=$(date --date="This Mon" +%b%d | tr A-Z a-z) # today is monday
    printf "today is monday.\n"
  else
    date=$(date --date="Last Mon" +%b%d | tr A-Z a-z) # today is NOT monday
    printf "today is NOT monday.\n"
  fi
fi

filepath="/home/n8/dox/plan/weekly/$date/$date"
directory="/home/n8/dox/plan/weekly/$date/"
template="/home/n8/dox/plan/weekly/template"

if [ -n "$1" ];
then

  if [ "$1" == f ]; then
    if [ -f $filepath.md ];
    then
      markdown $filepath.md > $filepath.html
      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