From 4815b0a349220c43c0b10ae091245d15f4283301 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Mon, 31 Jan 2022 19:44:12 -0800 Subject: [PATCH] ned: add safeguard for when fzf doesn't find a directory or is ctrl-c'd --- .config/shell/bin/ned | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/shell/bin/ned b/.config/shell/bin/ned index 650bde2..6c2c8db 100755 --- a/.config/shell/bin/ned +++ b/.config/shell/bin/ned @@ -42,7 +42,7 @@ edit() { SEARCH_TERM="$2" fi - NOTE_PATH="$NOTES_DIR/$(cd "$NOTES_DIR" && fzf -1 -q "$SEARCH_TERM" --layout=reverse --info=inline --height=10%)" + NOTE_PATH="$NOTES_DIR/$(cd "$NOTES_DIR" && fzf -1 -q "$SEARCH_TERM" --layout=reverse --info=inline --height=10%)" || exit $EDITOR_CMD "$NOTE_PATH" } @@ -59,6 +59,7 @@ new() { NOTE_NAME="$(date +'%F').md" fi + # TODO: use fzf instead of fd + fzf for picking the directory NOTE_PATH="$(fd -ad 1 "^$2" "$NOTES_DIR")" # check if there were no results if [ -z "$NOTE_PATH" ]; then