diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/extra/notes_index | 40 | ||||
| -rwxr-xr-x | bin/extra/routine | 32 | ||||
| -rw-r--r-- | bin/menuscripts/.gitignore | 1 | 
3 files changed, 73 insertions, 0 deletions
diff --git a/bin/extra/notes_index b/bin/extra/notes_index new file mode 100755 index 0000000..9ccb3b2 --- /dev/null +++ b/bin/extra/notes_index @@ -0,0 +1,40 @@ +#!/bin/sh + +NOTES="$HOME"/notes + +if ! [ -d "$NOTES" ]; then +    >&2 printf 'No notes directory.\n' +    exit 1 +fi + +cd "$NOTES" + +find . -type d | while read -r d +do +    cd "$d" +    printf '# Notes\n' > index.md +    find . \ +		-maxdepth 1 \ +		-type f \ +		-name '*.md' \ +		-not \ +		-name 'index.md' \ +		-printf '%f ' \ +		-exec grep '^# ' -m1 {} \; | +            sed 's/\(.\+\.md\) # \(.\+\)/- [\2](\1)/' | +            sort -t '[' -k 2 >> index.md + +    if [ "$(find . -mindepth 2 -maxdepth 2 -type f -name '*.md' | wc -l)" -gt 0 ] +    then +        printf '# Dirs\n' >> index.md +        find . \ +            -mindepth 1 \ +            -maxdepth 1 \ +            -type d \ +            -not -name '.*'\ +            -printf '- [%f](%f/index.md)\n' |  +                sort -t '[' -k 2 >> index.md +    fi + +    cd - > /dev/null +done 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 diff --git a/bin/menuscripts/.gitignore b/bin/menuscripts/.gitignore new file mode 100644 index 0000000..603cd6e --- /dev/null +++ b/bin/menuscripts/.gitignore @@ -0,0 +1 @@ +.scheduler.pid  | 
