From 635b495e0a388261e64afbf47da6f199e8e4d819 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Thu, 20 Jan 2022 03:18:04 -0800 Subject: [PATCH] zsh: ned: progress --- .config/shell/bin/ned | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.config/shell/bin/ned b/.config/shell/bin/ned index 3edf8df..ed2e947 100755 --- a/.config/shell/bin/ned +++ b/.config/shell/bin/ned @@ -2,20 +2,32 @@ # NEd: Note Editor (and your best friend!) # Ned can edit and create notes in a folder you tell him to! -NOTES_DIR="$HOME/Documents/college/2y/2q/" +# shellcheck disable=SC2068 + +# set default value for $NOTES_DIR +${NOTES_DIR:="$HOME/Documents/college/2y/2q/"} [ -d "$NOTES_DIR"/misc ] && mkdir "$NOTES_DIR/misc" -# Create misc note if blank +# Create misc note if no input if [ -z "$1" ]; then "$EDITOR" "$NOTES_DIR/unsorted/$(date)" zsh fi +new() { + if [ -z "$1" ]; then + "$EDITOR" "$NOTES_DIR/unsorted/$(date)" + zsh + fi + + "$EDITOR" "$NOTES_DIR/$2"*"/notes/$3" +} + # Parse arguments case "$1" in # create and edit new note - 'new'|'n') "$EDITOR" "$NOTES_DIR"/*"$2"*/notes/"$3";; + 'new'|'n') new $@;; # edit ned 'e') "$EDITOR" "$(realpath "$0")";; *) echo "no such option";;