From c61f97a55c39d0dbd760c1373da4eb72101496d3 Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 2 Sep 2021 20:41:21 +0200 Subject: [PATCH] Version 2.0 --- .zsh-integration | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .zsh-integration diff --git a/.zsh-integration b/.zsh-integration new file mode 100644 index 0000000..025e3d6 --- /dev/null +++ b/.zsh-integration @@ -0,0 +1,32 @@ +# NNotes +# basic CLI notes and todo inventory + +# internal vars +nnote_dir="$HOME/.nnotes" +nnote_local_file="$nnote_dir/$HOST/note.md" +ttodo_local_file="$nnote_dir/$HOST/todo.md" + +# create local folders if does not exist +if [[ ! -d "$nnote_dir/$HOST" ]]; then + mkdir $nnote_dir/$HOST + touch $nnote_local_file + touch $ttodo_local_file +fi + +# internal alias +alias nnote_gitadd="(cd $nnote_dir/ && git add $nnote_local_file && git commit -m \"update by $HOST\" && git push --quiet -u --no-progress)" +alias ttodo_gitadd="(cd $nnote_dir/ && git add $ttodo_local_file && git commit -m \"update by $HOST\" && git push --quiet -u --no-progress)" +alias nnote_pull="(cd $nnote_dir && git pull)" + + +# Print current todos into fresh spawned shell +if [[ ! -z $(grep '[^[:space:]]' $(printf "$nnote_dir" "$@")/$HOST/todo.md) ]]; then + echo '==============| Local ToDos |==============' + echo '' + tail "$nnote_dir/$HOST/todo.md" + echo '' +fi + +# external alias +alias nnote="nano $nnote_local_file && nnote_gitadd" +alias ttodo="nano $ttodo_local_file && ttodo_gitadd"