zsh: almost all functions are scripts now (part 2)
This commit is contained in:
parent
75c3986785
commit
ec0cee28d9
14 changed files with 287 additions and 0 deletions
40
.config/shell/bin/todo
Executable file
40
.config/shell/bin/todo
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# a simple way to manage your todo list
|
||||
# Usage:
|
||||
# todo -- pull latest repo version and edit ~/todo
|
||||
# todo [any git command] -- manage todo for easy syncing, assuming ~/todo is
|
||||
# a symlink that points to a file in a git repo
|
||||
#
|
||||
# Suggested use: make a git repo for holding your todo list, then make
|
||||
# a symlink called 'todo' that points to your todo list in your home directory
|
||||
#
|
||||
|
||||
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
|
||||
git rev-parse &&
|
||||
git pull
|
||||
|
||||
# open the file
|
||||
"$EDITOR" "$todo_file"
|
||||
|
||||
# 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
|
||||
fi
|
||||
)
|
||||
|
||||
elif [ "$@" = "cd" ]; then
|
||||
cd "$todo_dir"
|
||||
|
||||
else
|
||||
git -C "$todo_dir" $@
|
||||
|
||||
fi
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue