zsh: add todo cd to todo()

This commit is contained in:
PowerUser64 2021-09-26 13:37:33 -07:00
parent bba61c3b31
commit 1ed5ec20e6

11
.zshrc
View file

@ -172,10 +172,10 @@
# a symlink called 'todo' that points to your todo list in your home directory # a symlink called 'todo' that points to your todo list in your home directory
# #
todo() { todo() {
( # subshell to protect against directory changes
todo_dir="$(dirname "$(realpath ~/todo)")" todo_dir="$(dirname "$(realpath ~/todo)")"
todo_file="$(realpath ~/todo)" todo_file="$(realpath ~/todo)"
if [ -z "$@" ];then if [ -z "$@" ];then
( # subshell to protect against directory changes
cd "$todo_dir" cd "$todo_dir"
# pull the latest commits # pull the latest commits
@ -188,12 +188,17 @@
# commit and push the file if it's in a git repo and the file has changed # commit and push the file if it's in a git repo and the file has changed
if git rev-parse && ! git diff --exit-code "$todo_file"; then if git rev-parse && ! git diff --exit-code "$todo_file"; then
git commit "$todo_file" -m 'todo' && git commit "$todo_file" -m 'todo' &&
git push git push
fi fi
)
elif [ "$@" = "cd" ]; then
cd "$todo_dir"
else else
git -C "$todo_dir" $@ git -C "$todo_dir" $@
fi fi
)
} }
# Simple extraction script. Taken from manjaro's .bashrc # Simple extraction script. Taken from manjaro's .bashrc