From fadea7197898268d7cfed436337a144c697eeb69 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Fri, 18 Mar 2022 17:53:05 -0700 Subject: [PATCH] todo: rename variables + allow for defaults --- .config/shell/functions/todo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.config/shell/functions/todo b/.config/shell/functions/todo index a388225..7f0d536 100644 --- a/.config/shell/functions/todo +++ b/.config/shell/functions/todo @@ -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 }