From 410907e5674227bc1ed03322f46d5b9189b8ea57 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Sun, 13 Nov 2022 00:13:33 +0800 Subject: Fix editor command error EDITOR may contain arguments. When using "$EDITOR", the argument will be taken as part of the binary to execute. --- wd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wd b/wd index 7e62181..f43b6af 100755 --- a/wd +++ b/wd @@ -17,6 +17,8 @@ Usage: $PROGRAM journal $PROGRAM edit + $PROGRAM git [] + Run git command in $WD_NOTES_DIR _EOF exit 0 @@ -28,7 +30,7 @@ cmd_version () { } cmd_edit () { - cd "$WD_NOTES_DIR" && $EDITOR "$WD_NOTES_DIR/index.md" + $EDITOR "$WD_NOTES_DIR/index.md" exit 0 } @@ -58,16 +60,21 @@ cmd_journal () { [ ! -f "$file_to_edit" ] && echo "$file_title" > "$file_to_edit" grep -qF "$file_subtitle" "$file_to_edit" || echo "$file_subtitle" >> "$file_to_edit" - cd "$WD_NOTES_DIR" && $EDITOR "$file_to_edit" + $EDITOR "$file_to_edit" exit 0 } +cmd_git () { + cd "$WD_NOTES_DIR" && git "$@" +} + case "$1" in help|--help|-h) shift; cmd_usage "$@";; version|--version|-v) shift; cmd_version "$@";; journal|j) shift; cmd_journal "$@";; edit|e) shift; cmd_edit "$@";; + git|g) shift; cmd_git "$@" ;; *) cmd_usage "$@";; esac -- cgit v1.2.3