zsh: add todo cd to todo()
This commit is contained in:
parent
bba61c3b31
commit
1ed5ec20e6
1 changed files with 8 additions and 3 deletions
11
.zshrc
11
.zshrc
|
@ -172,10 +172,10 @@
|
|||
# a symlink called 'todo' that points to your todo list in your home directory
|
||||
#
|
||||
todo() {
|
||||
( # subshell to protect against directory changes
|
||||
todo_dir="$(dirname "$(realpath ~/todo)")"
|
||||
todo_file="$(realpath ~/todo)"
|
||||
if [ -z "$@" ];then
|
||||
( # subshell to protect against directory changes
|
||||
cd "$todo_dir"
|
||||
|
||||
# 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
|
||||
if git rev-parse && ! git diff --exit-code "$todo_file"; then
|
||||
git commit "$todo_file" -m 'todo' &&
|
||||
git push
|
||||
git push
|
||||
fi
|
||||
)
|
||||
|
||||
elif [ "$@" = "cd" ]; then
|
||||
cd "$todo_dir"
|
||||
|
||||
else
|
||||
git -C "$todo_dir" $@
|
||||
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
# Simple extraction script. Taken from manjaro's .bashrc
|
||||
|
|
Loading…
Add table
Reference in a new issue