improved todo()

This commit is contained in:
PowerUser64 2021-09-15 22:02:47 -07:00
parent a8b6b58964
commit c2e6e88e27

12
.zshrc
View file

@ -158,11 +158,13 @@
# an improved way to manage the todo list # an improved way to manage the todo list
todo() { todo() {
( ( # subshell to protect against directory changes
cd "$(dirname "$(realpath ~/todo)")" if [ -z "$@" ];then
# only pull the repo if there is some argument $EDITOR ~/todo
[ -z "$1" ] || test -d .git || git rev-parse --git-dir > /dev/null 2>&1 && echo 'pulling repository' && git pull else
"$EDITOR" ~/todo cd "$(dirname "$(realpath ~/todo)")"
git $@
fi
) )
} }