diff options
Diffstat (limited to 'bin/extra/routine')
-rwxr-xr-x | bin/extra/routine | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/extra/routine b/bin/extra/routine new file mode 100755 index 0000000..e03d471 --- /dev/null +++ b/bin/extra/routine @@ -0,0 +1,32 @@ +#!/bin/sh + +# Dependencies: +# - fzf + +routine="$HOME/sync/share/routine.md" +if [ ! -r "$routine" ]; then + >&2 printf 'No routine file at %s\n' "$routine" + exit 1 +fi + +case "$1" in + "clear") + new="$routine.$$" + sed 's/\[x]/[ ]/' "$routine" > "$new" + mv "$new" "$routine" + ;; + "edit") + $EDITOR "$routine" + ;; + "done") + grep "^- \[ ]" "$routine" > /dev/null || exit 1 + t="$(grep "^- \[ ]" "$routine" | fzf)" + [ "$t" ] || exit 2 + new="$routine.$$" + sed "/${t#- [ }/s/\[ ]/[x]/" "$routine" >> "$new" + mv "$new" "$routine" + ;; + "") + cat "$routine" + ;; +esac |