From c9ea66f4d1b162d86bb4c1a5fc285c6d95500330 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Sun, 20 Nov 2022 23:14:08 +0800 Subject: Enhance edit command It can now edit not only index.md --- wd | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 } -- cgit v1.2.3