xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.64k stars 188 forks source link

Note Review #242

Open jupart opened 1 year ago

jupart commented 1 year ago

An important part of my workflow is reviewing notes to prune, organize, and combine notes. I've written a script to iterate over notes in a notebook, display them, and prompt for deletion, edit, or simply skipping. I think this functionality might be more useful integrated in nb, but think of this as a proof of concept.

#!/usr/bin/fish
#
# must pass valid notebook name

set -l notebook $argv[1]
if not nb notebook $notebook
    echo "Run nb_review with a valid nb notebook"
    return
end
set -l nb_filenames (nb $notebook:run ls)

for filename in $nb_filenames
    set -l id (nb $notebook:index get_id $filename)
    nb $notebook:show $id | cat
    read answer -p "echo; set_color -o -u red; printf '(d)elete (e)dit (c)ontinue'; set_color normal; printf ': '"
    switch $answer
        case "d"
            echo "Deleting $filename"
            nb $notebook:delete --force $id
        case "e"
            nb $notebook:edit $id
        case "c"
            echo "Skipping $filename"
    end
    clear
end