- #!/bin/sh
-
- # Output a vimwiki diary page template for a given diary page path
- # (which is expected to be a date in YYYY-MM-DD format).
-
- if [ ! -z "$1" ]; then
- # Take the basename of the file passed in, i.e. something like
- # /home/brennen/notes/vimwiki/diary/2019-01-01.wiki, slice off the extension,
- # and treat it as a seed date:
- date="$(basename -s .wiki "$1")"
- date="$(basename -s .md "$date")"
- datestamp="$(fragment-today "$date")"
- else
- # No filename given, nothing to work with, just use today:
- datestamp="$(fragment-today)"
- fi
-
- grep_logs="$(fragment-vimwiki-grep-logs "$1")"
-
- # -t sets date
- # -A 14 is two weeks ahead
- calendar_datestamp="$(date --date="$date" '+%Y-%m-%d')"
- calendar="{{{exec-raw notes calendar $calendar_datestamp # calendar
- }}}"
-
- printf '= %s =\n\n%%%% exec-raw auto\n%%%% nowrap\n\n%s\n\n== calendar ==\n\n%s' \
- "$datestamp" \
- "$grep_logs" \
- "$calendar"
|