diff options
author | Guangxiong Lin <[email protected]> | 2022-11-13 00:13:33 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2022-11-13 00:13:33 +0800 |
commit | 410907e5674227bc1ed03322f46d5b9189b8ea57 (patch) | |
tree | 6f670615876fed79e7ef0135903050076daa898f | |
parent | 8671b7b71a4b44db9144eaeb603ec94212cb94b3 (diff) | |
download | wd-410907e5674227bc1ed03322f46d5b9189b8ea57.tar.gz wd-410907e5674227bc1ed03322f46d5b9189b8ea57.tar.bz2 wd-410907e5674227bc1ed03322f46d5b9189b8ea57.zip |
Fix editor command error
EDITOR may contain arguments. When using "$EDITOR", the argument will be
taken as part of the binary to execute.
-rwxr-xr-x | wd | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -17,6 +17,8 @@ Usage: $PROGRAM journal $PROGRAM edit + $PROGRAM git [<args>] + 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 |