todo: rename variables + allow for defaults
This commit is contained in:
parent
b0d9876558
commit
fadea71978
1 changed files with 8 additions and 8 deletions
|
@ -12,29 +12,29 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
todo() {
|
todo() {
|
||||||
todo_dir="$(dirname "$(realpath ~/todo)")"
|
TODO_DIR="${FDOC:-"$(dirname "$(realpath ~/todo)")"}"
|
||||||
todo_file="$(realpath ~/todo)"
|
TODO_FILE="${FTD:-"$(realpath ~/todo)"}"
|
||||||
if [ -z "$*" ];then
|
if [ -z "$*" ];then
|
||||||
( # subshell to protect against directory changes
|
( # subshell to protect against directory changes
|
||||||
cd "$todo_dir" || return
|
cd "$TODO_DIR" || return
|
||||||
|
|
||||||
# pull the latest commits
|
# pull the latest commits
|
||||||
git rev-parse &&
|
git rev-parse &&
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
# open the file
|
# open the file
|
||||||
"$EDITOR" "$todo_file"
|
$EDITOR "$TODO_FILE"
|
||||||
|
|
||||||
# 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
|
elif [ "$*" = "cd" ]; then
|
||||||
cd "$todo_dir" || return
|
cd "$TODO_DIR" || return
|
||||||
else
|
else
|
||||||
git -C "$todo_dir" $@
|
git -C "$TODO_DIR" $@
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue