diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-08 14:54:50 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-08 14:54:50 +0200 |
commit | e73e19e82a893bacd3c1da87835bc066aa69bb23 (patch) | |
tree | 3118beecdcda549b16b7eea0c628ae9c517f18e2 /bin/extra/routine | |
parent | 7a91a55b79f828017b38c9f0af479b25c89bf6a9 (diff) |
checkpoint
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 |