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_dir="$(dirname "$(realpath ~/todo)")"
|
||||
todo_file="$(realpath ~/todo)"
|
||||
TODO_DIR="${FDOC:-"$(dirname "$(realpath ~/todo)")"}"
|
||||
TODO_FILE="${FTD:-"$(realpath ~/todo)"}"
|
||||
if [ -z "$*" ];then
|
||||
( # subshell to protect against directory changes
|
||||
cd "$todo_dir" || return
|
||||
cd "$TODO_DIR" || return
|
||||
|
||||
# pull the latest commits
|
||||
git rev-parse &&
|
||||
git pull
|
||||
|
||||
# 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
|
||||
if git rev-parse && ! git diff --exit-code "$todo_file"; then
|
||||
git commit "$todo_file" -m 'todo' &&
|
||||
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" || return
|
||||
cd "$TODO_DIR" || return
|
||||
else
|
||||
git -C "$todo_dir" $@
|
||||
git -C "$TODO_DIR" $@
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue