summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-11-13 00:13:33 +0800
committerGuangxiong Lin <[email protected]>2022-11-13 00:13:33 +0800
commit410907e5674227bc1ed03322f46d5b9189b8ea57 (patch)
tree6f670615876fed79e7ef0135903050076daa898f
parent8671b7b71a4b44db9144eaeb603ec94212cb94b3 (diff)
downloadwd-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-xwd11
1 files 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 [<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