From e73e19e82a893bacd3c1da87835bc066aa69bb23 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 8 Oct 2024 14:54:50 +0200 Subject: checkpoint --- bin/extra/routine | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/extra/routine (limited to 'bin/extra/routine') 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 -- cgit v1.2.3