#!/bin/sh set -eu type agenda >/dev/null if [ "${AGENDA_EXTENSION:-}" != "xit" ]; then exit fi # Capitalize the title. echo "$AGENDA_NAME $AGENDA_DATE" | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}' if [ -n "${AGENDA_IS_BACKLOG:-}" ]; then exit fi # Carry over open tasks from the last agenda xit file. if [ -e "$AGENDA_LAST" ] && [ "${AGENDA_LAST#*.}" = "xit" ]; then line=0 while IFS= read -r REPLY; do line=$(( line + 1 )) case ${state:-} in "open_task") case $REPLY in "[ ] "*|"[@] "*|"[?] "*|" "*) # Append indented lines to open tasks. echo "$REPLY" ;; *) unset state ;; esac ;; *) case $REPLY in "[ ] "*|"[@] "*|"[?] "*) # Carry over group heading with open tasks. if [ -n "${header:-}" ]; then echo echo "$header" unset header fi state="open_task" echo "$REPLY" ;; [a-z]*|[A-Z]*) # Skip the first heading (assumed to be the generated # title of the agenda note). if [ $line -gt 1 ]; then header=$REPLY fi ;; esac ;; esac done < "$AGENDA_LAST" fi