diff --git a/.zshrc b/.zshrc index 430fc25..1a3f4f1 100644 --- a/.zshrc +++ b/.zshrc @@ -159,15 +159,20 @@ # an improved way to manage the todo list # Usage: # todo -- edit ~/todo + # todo auto -- commit ~/todo and push with message 'todo' # todo [git command string] -- manage todo for easy syncing, assuming ~/todo is # a symlink that points to a file in a git repo todo() { ( # subshell to protect against directory changes + todo_dir="$(dirname "$(realpath ~/todo)")" if [ -z "$@" ];then cd "$(dirname "$(realpath ~/todo)")" $EDITOR ~/todo + elif [ "$@" = 'auto' ];then + cd "$todo_dir" + git commit "$(realpath ~/todo)" -m 'todo' && todo push else - cd "$(dirname "$(realpath ~/todo)")" + cd "$todo_dir" git $@ fi )