all repos — dotfiles @ 48c1468058a4792ef0b357dc6e9debef46525933

linux dotfiles

scripts/zet: add functions

- print function
- make commit when edited
- add tags when listing zets
Prithu Goswami pg@prithu.dev
Thu, 28 Apr 2022 00:08:28 +0530
commit

48c1468058a4792ef0b357dc6e9debef46525933

parent

aeed57fcaa806ec6436a9ea390e5b930da373825

1 files changed, 16 insertions(+), 1 deletions(-)

jump to
M bin/scripts/zetbin/scripts/zet

@@ -11,7 +11,8 @@ list(){

for a in $ZET_DIR/* do title=$(cat $a | head -1) - printf '%s: %s\n' `basename $a` "${title/\# }" + tags=$(cat $a | tail -1 | grep '^tags:.*$' | sed 's/tags:/# /') # replace with pure bash later + printf '%s: %s %s\n' `basename $a` "${title/\# }" "$tags" done }

@@ -49,5 +50,19 @@ if [ "$choice" ]

then filename="$(echo $choice | cut -d: -f1)" vim $ZET_DIR/$filename + t=$(cat $ZET_DIR/$filename | head -1) + title=$(printf "%s" "${t/\# }") + cd $ZET_DIR + git add $filename + git commit -m "zet: $title" > /dev/null + echo "Edited zet $ZET_DIR/$filename" + fi + ;; + print|p) + choice=$(list | fzf --tac) + if [ "$choice" ] + then + filename="$(echo $choice | cut -d: -f1)" + cat $ZET_DIR/$filename fi esac