summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-11-20 23:14:08 +0800
committerGuangxiong Lin <[email protected]>2022-11-20 23:47:11 +0800
commitc9ea66f4d1b162d86bb4c1a5fc285c6d95500330 (patch)
tree019ae12678a4c967fc48cde2cc3feb6a2a145806
parentac8791df68c515a57be4696d70ed382fe31a37d0 (diff)
downloadwd-c9ea66f4d1b162d86bb4c1a5fc285c6d95500330.tar.gz
wd-c9ea66f4d1b162d86bb4c1a5fc285c6d95500330.tar.bz2
wd-c9ea66f4d1b162d86bb4c1a5fc285c6d95500330.zip
Enhance edit command
It can now edit not only index.md
-rwxr-xr-xwd10
1 files changed, 9 insertions, 1 deletions
diff --git a/wd b/wd
index 1a2e1f2..5880f98 100755
--- a/wd
+++ b/wd
@@ -7,6 +7,7 @@ PROGRAM="$(basename $0)"
WD_NOTES_DIR=${WD_NOTES_DIR:-"$HOME/notes"}
WD_JOURNALS_DIR=${WD_JOURNALS_DIR:-"$WD_NOTES_DIR/journals"}
+WD_INDEX_FILE=${WD_INDEX_FILE:-index.md}
WD_DEFAULT_SUBCOMMAND=${WD_DEFAULT_SUBCOMMAND:-help}
year=$(date +%Y)
@@ -31,7 +32,14 @@ cmd_version () {
}
cmd_edit () {
- $EDITOR "$WD_NOTES_DIR/index.md"
+ local file
+ if [ "$#" -eq 0 ]; then
+ file="$WD_INDEX_FILE"
+ else
+ file="$1"
+ fi
+
+ $EDITOR "$WD_NOTES_DIR/$file"
exit 0
}