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.

24 lines
800 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. calendar_datestamp="$(date --date="$date" '+%Y%m%d')"
  17. calendar="{{{exec-raw calendar -t \"$calendar_datestamp\"
  18. }}}"
  19. printf '= %s =\n\n%s\n\n== calendar ==\n\n%s' "$datestamp" "$grep_logs" "$calendar"