ned: add safeguard for when fzf doesn't find a directory or is ctrl-c'd

This commit is contained in:
PowerUser64 2022-01-31 19:44:12 -08:00
parent ec271021a8
commit 4815b0a349

View file

@ -42,7 +42,7 @@ edit() {
SEARCH_TERM="$2" SEARCH_TERM="$2"
fi 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" $EDITOR_CMD "$NOTE_PATH"
} }
@ -59,6 +59,7 @@ new() {
NOTE_NAME="$(date +'%F').md" NOTE_NAME="$(date +'%F').md"
fi fi
# TODO: use fzf instead of fd + fzf for picking the directory
NOTE_PATH="$(fd -ad 1 "^$2" "$NOTES_DIR")" NOTE_PATH="$(fd -ad 1 "^$2" "$NOTES_DIR")"
# check if there were no results # check if there were no results
if [ -z "$NOTE_PATH" ]; then if [ -z "$NOTE_PATH" ]; then