From e3fa159136440d182bee310084aa1c214e2e1b97 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 15 Sep 2021 22:02:47 -0700 Subject: [PATCH] improved todo() --- .zshrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.zshrc b/.zshrc index 502b299..a4f1173 100644 --- a/.zshrc +++ b/.zshrc @@ -158,11 +158,13 @@ # an improved way to manage the todo list todo() { - ( - cd "$(dirname "$(realpath ~/todo)")" - # only pull the repo if there is some argument - [ -z "$1" ] || test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull - "$EDITOR" ~/todo + ( # subshell to protect against directory changes + if [ -z "$@" ];then + $EDITOR ~/todo + else + cd "$(dirname "$(realpath ~/todo)")" + git $@ + fi ) }