Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
901 B

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