From b942b31f2a22319925059b8ea2409347cfa240dd Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Tue, 21 Sep 2021 21:18:41 -0700 Subject: [PATCH] zsh: made todo() more logical, committing and pushing after each edit --- .zshrc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.zshrc b/.zshrc index 79ccc3f..b60cc65 100644 --- a/.zshrc +++ b/.zshrc @@ -162,7 +162,6 @@ # a simple way to manage your todo list # Usage: # todo -- pull latest repo version and edit ~/todo - # todo auto -- commit and push ~/todo with message 'todo' # todo [any git command] -- manage todo for easy syncing, assuming ~/todo is # a symlink that points to a file in a git repo # @@ -174,12 +173,17 @@ todo_dir="$(dirname "$(realpath ~/todo)")" if [ -z "$@" ];then cd "$(dirname "$(realpath ~/todo)")" - git rev-parse && git pull - $EDITOR ~/todo - elif [ "$@" = 'auto' ];then - cd "$todo_dir" - git commit "$(realpath ~/todo)" -m 'todo' - git push + + # pull the latest commits + git rev-parse && + git pull + + "$EDITOR" ~/todo + + # commit and push the file if it's in a git repo + git rev-parse && + git commit "$(realpath ~/todo)" -m 'todo' && + git push else cd "$todo_dir" git $@