From 230a1b717a8b2b2d94e785d6bf3282f1227dd978 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 17 Nov 2024 04:08:06 +0000 Subject: [PATCH] Add a note preview to fzf --- README.md | 2 +- notes.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc2ecdc..1f68335 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Then add the following aliases to your `~/.bashrc`: alias nn="notes.sh -n" # Type "ne" to look up and edit an existing note -alias ne="notes.sh -l | fzf --tac --with-nth=\"2..-1\" | xargs -o notes.sh -e" +alias ne="notes.sh -l | fzf --tac --with-nth=\"2..-1\" --preview \"notes.sh -p {}\" | xargs -o notes.sh -e" ``` To add a new note: diff --git a/notes.sh b/notes.sh index a70991f..aa84de5 100755 --- a/notes.sh +++ b/notes.sh @@ -195,6 +195,15 @@ while (( "$#" )); do export_note "$2" "$3" exit 0 ;; + -p|--preview) + if [ -z "$2" ]; then + echo "Misssing arguments for $1" + exit 1 + fi + NOTE_ID="$(echo $2 | cut -d " " -f 1)" + export_note "$NOTE_ID" "" + exit 0 + ;; -g|--graph) get_graph exit 0