zsh: more enhancements to todo()
This commit is contained in:
parent
b942b31f2a
commit
c9b000765e
1 changed files with 9 additions and 7 deletions
16
.zshrc
16
.zshrc
|
@ -171,22 +171,24 @@
|
||||||
todo() {
|
todo() {
|
||||||
( # subshell to protect against directory changes
|
( # subshell to protect against directory changes
|
||||||
todo_dir="$(dirname "$(realpath ~/todo)")"
|
todo_dir="$(dirname "$(realpath ~/todo)")"
|
||||||
|
todo_file="$(realpath ~/todo)"
|
||||||
if [ -z "$@" ];then
|
if [ -z "$@" ];then
|
||||||
cd "$(dirname "$(realpath ~/todo)")"
|
cd "$todo_dir"
|
||||||
|
|
||||||
# pull the latest commits
|
# pull the latest commits
|
||||||
git rev-parse &&
|
git rev-parse &&
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
"$EDITOR" ~/todo
|
# open the file
|
||||||
|
"$EDITOR" "$todo_file"
|
||||||
|
|
||||||
# commit and push the file if it's in a git repo
|
# commit and push the file if it's in a git repo and the file has changed
|
||||||
git rev-parse &&
|
if git rev-parse && ! git diff --exit-code "$todo_file"; then
|
||||||
git commit "$(realpath ~/todo)" -m 'todo' &&
|
git commit "$todo_file" -m 'todo' &&
|
||||||
git push
|
git push
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
cd "$todo_dir"
|
git -C "$todo_dir" $@
|
||||||
git $@
|
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue