Just nb install fzf.nb-plugin
and nb fzf
.
alias nbf
“nb fzf”= if you’re feeling frisky.
Done.
I mean, not really, because cielagonote does the whole “make it if it doesn’t exist” thing, and it’s doing full-text search. But if the thing you don’t like about nb is “list, get a number, enter a number” to operate on your file, this does the job.
#!/usr/bin/env bash
###############################################################################
# fzf.nb-plugin
#
# FZF Plugin for nb
#
###############################################################################
# Add the new subcommand name with `_subcommands add <name>`.
_subcommands add "fzf"
# Define help and usage text with `_subcommands describe <subcommand> <usage>`.
_subcommands describe "fzf" <<HEREDOC
Usage:
nb fzf
Description:
Search through current notebook using fzf and then edit sepected item.
HEREDOC
_fzf() {
local note=$(_ls -t note --filename -a --no-footer --no-header --no-indicator --tree | fzf --ansi --header "$(_notebook current --name)" --preview "echo {} | sed '"'s/\x1b\[[0-9;]*m//g'"' | awk -F'[][]' '"'{print $2}'"' | xargs -n 1 nb show -p | ${NB_MARKDOWN_TOOL:-bat} -" | awk -F'[][]' '{print $2}')
if ! [[ -z "$note" ]]; then
command nb edit "$note"
fi
}