notes.sh

CLI and local web note-taking, bookmarking, and archiving with encryption, search, Git-backed versioning and syncing, tagging, and more in a single portable script.

Usage no npm install needed!

<script type="module">
  import notesSh from 'https://cdn.skypack.dev/notes.sh';
</script>

README

nb

Build Status


nb is a command line and local web note‑taking, bookmarking, archiving, and knowledge base application with:

and more, in a single portable script.

nb creates notes in text-based formats like Markdown, Org, and LaTeX, can work with files in any format, can import and export notes to many document formats, and can create private, password-protected encrypted notes and bookmarks. With nb, you can write notes using Vim, Emacs, VS Code, Sublime Text, and any other text editor you like, as well as terminal and GUI web browsers. nb works in any standard Linux / Unix environment, including macOS and Windows via WSL. Optional dependencies can be installed to enhance functionality, but nb works great without them.

home

nb is also a powerful bookmarking system featuring:

  • locally-served, text-centric, distraction-free bookmark browsing in terminal and GUI web browsers,
  • local full-text search of cached page content with regular expression support,
  • convenient filtering and listing,
  • Internet Archive Wayback Machine snapshot lookup for broken links,
  • tagging, pinning, linking, and full integration with other nb features.

Page information is downloaded, cleaned up, structured, and saved into normal Markdown documents made for humans, so bookmarks are easy to view and edit just like any other note.

nb browse

nb uses Git in the background to automatically record changes and sync notebooks with remote repositories. nb can also be configured to sync notebooks using a general purpose syncing utility like Dropbox so notes can be edited in other apps on any device.

nb list empty

nb is designed to be portable, future-focused, and vendor independent, providing a full-featured and intuitive experience within a highly composable multimodal user-centric text interface. The entire program is contained within a single well-tested shell script that can be installed, copied, or curled almost anywhere and just work, using a strategy inspired by progressive enhancement for various experience improvements in more capable environments. nb works great whether you have one notebook with just a few notes or dozens of notebooks containing thousands of notes, bookmarks, and other items. nb makes it easy to incorporate other tools, writing apps, and workflows. nb can be used a little, a lot, once in a while, or for just a subset of features. nb is flexible.

πŸ“ πŸ”– πŸ”’ πŸ” πŸ“”


nb

Installation Β· Overview  

Help

 β†‘ 

Installation

Dependencies

Required
Optional

nb leverages standard command line tools and works in standard Linux / Unix environments. nb also checks the environment for some additional optional tools and uses them to enhance the experience whenever they are available.

Recommended:

Also supported for various enhancements:

Ack, afplay, Ag - The Silver Searcher, catimg, exa, ffplay, ImageMagick, GnuPG, highlight, imgcat, kitty's icat kitten, Links, Lynx, Midnight Commander, mpg123, MPlayer, ncat, note-link-janitor (via plugin), pdftotext, Pygments, Ranger, readability-cli, rga / ripgrep-all, termpdf.py, vifm

macOS / Homebrew

brew tap xwmx/taps
brew install nb

Installing nb with Homebrew also installs the recommended dependencies above and completion scripts for Bash and Zsh.

Ubuntu, Windows WSL, and others

npm
npm install -g nb.sh

After npm installation completes, run sudo "$(which nb)" completions install to install Bash and Zsh completion scripts (recommended).

On Ubuntu and WSL, you can run sudo "$(which nb)" env install to install the optional dependencies.

nb is also available under its original package name, notes.sh, which comes with an extra notes executable wrapping nb.

Download and Install

To install as an administrator, copy and paste one of the following multi-line commands:

# install using wget
sudo wget https://raw.github.com/xwmx/nb/master/nb -O /usr/local/bin/nb &&
  sudo chmod +x /usr/local/bin/nb &&
  sudo nb completions install

# install using curl
sudo curl -L https://raw.github.com/xwmx/nb/master/nb -o /usr/local/bin/nb &&
  sudo chmod +x /usr/local/bin/nb &&
  sudo nb completions install

On Ubuntu and WSL, you can run sudo nb env install to install the optional dependencies.

User-only Installation

To install with just user permissions, simply add the nb script to your $PATH. If you already have a ~/bin directory, for example, you can use one of the following commands:

# download with wget
wget https://raw.github.com/xwmx/nb/master/nb -O ~/bin/nb && chmod +x ~/bin/nb

# download with curl
curl -L https://raw.github.com/xwmx/nb/master/nb -o ~/bin/nb && chmod +x ~/bin/nb

Installing with just user permissions doesn't include the optional dependencies or completions, but nb core functionality works without them. If you have sudo access and want to install the completion scripts and dependencies, run the following command:

sudo nb env install
Make

To install with Make, clone this repository, navigate to the clone's root directory, and run:

sudo make install

This will also install the completion scripts on all systems and the recommended dependencies on Ubuntu and WSL.

bpkg

To install with bpkg:

bpkg install xwmx/nb

Tab Completion

Bash, Fish, and Zsh tab completion should be enabled when nb is installed using the methods above, assuming you have the appropriate system permissions or installed with sudo. If completion isn't working after installing nb, see the completion installation instructions.

Updating

When nb is installed using a package manager like npm or Homebrew, use the package manager's upgrade functionality to update nb to the latest version. When installed via other methods, nb can be updated to the latest version using the nb update subcommand.

Overview

πŸ“ Notes Β· Adding Β· Listing Β· Editing Β· Viewing Β· Deleting Β· πŸ”– Bookmarks Β· βœ… Todos Β· βœ”οΈ Tasks Β· 🏷 Tagging Β· πŸ”— Linking Β· 🌍 Browsing Β· πŸŒ„ Images Β· πŸ—‚ Zettelkasten Β· πŸ“‚ Folders Β· πŸ“Œ Pinning Β· πŸ” Search Β· ↔ Moving & Renaming Β· πŸ—’ History Β· πŸ“š Notebooks Β· πŸ”„ Git Sync Β· ↕️ Import / Export Β· βš™οΈset&settings Β· 🎨 Color Themes Β· πŸ”Œ Plugins Β· :/ Selectors Β· 01 Metadata Β· ❯ Shell Β· Shortcuts Β· Help Β· Specifications Β· Tests

 β†‘ 

To get started, simply run:

nb

nb sets up your initial home notebook the first time it runs.

By default, notebooks and notes are global (at ~/.nb), so they are always available to nb regardless of the current working directory. nb also supports local notebooks.

πŸ“ Notes

Adding

↑ Β· nb add, nb browse add

Use nb add (shortcuts: nb a, nb +) to create new notes:

# create a new note in your text editor
nb add

# create a new note with the filename "example.md"
nb add example.md

# create a new note containing "This is a note."
nb add "This is a note."

# create a new note with piped content
echo "Note content." | nb add

# create a new password-protected, encrypted note titled "Secret Document"
nb add --title "Secret Document" --encrypt

# create a new note in the notebook named "example"
nb example:add "This is a note."

# create a new note in the folder named "sample"
nb add sample/

nb add with no arguments or input will open the new, blank note in your environment's preferred text editor. You can change your editor using the $EDITOR environment variable or nb set editor.

nb files are Markdown files by default. The default file type can be changed to whatever you like using nb set default_extension.

nb add has intelligent argument parsing and behaves differently depending on the types of arguments it receives. When a filename with extension is specified, a new note with that filename is opened in the editor:

nb add example.md

When a string is specified, a new note is immediately created with that string as the content and without opening the editor:

❯ nb add "This is a note."
Added: [1] 20200101000000.md

nb add <string> is useful for quickly jotting down notes directly via the command line. Quoting content is optional, but recommended.

When no filename is specified, nb add uses the current datetime as the filename.

nb add can also receive piped content, which behaves the same as nb add <string>:

# create a new note containing "Note content."
❯ echo "Note content." | nb add
Added: [6] 20200101000100.md

# create a new note containing the clipboard contents on macOS
❯ pbpaste | nb add
Added: [7] 20200101000200.md

# create a new note containing the clipboard contents using xclip
❯ xclip -o | nb add
Added: [8] 20200101000300.md

Content can be passed with the --content <content> option, which also creates a new note without opening the editor:

nb add --content "Note content."

When content is piped, specified with --content <content>, or passed as a string argument, use the --edit flag to open the file in the editor before the change is committed.

The title, filename, and content can also be specified with long and short options:

❯ nb add --filename "example.md" -t "Example Title" -c "Example content."
Added: [9] example.md "Example Title"

The -t <title> / --title <title> option also sets the filename to the title, lowercased with spaces and non-filename characters replaced with underscores:

❯ nb add --title "Example Title" "Example content."
Added: [10] example_title.md "Example Title"

Tags can be added with the --tags <tag1>,<tag2>... option, which takes a comma separated list of tags, converts them to #hashtags, and inserts them between the title and content:

❯ nb add "Example content." --title "Tagged Example" --tags tag1,tag2
Added: [11] tagged_example.md "Tagged Example"

❯ nb show 11 --print
# Tagged Example

#tag1 #tag2

Example content.

Search for tagged items with nb search / nb q:

# search for items tagged with "#tag1"
nb search --tag tag1

# search for items tagged with "#tag1" AND "#tag2", short options
nb q -t tag1 -t tag2

# search for items tagged with "#tag1" OR "#tag2", arguments
nb q \#tag1 --or \#tag2

Files can be created with any file type by specifying the extension either in the filename (example.md), the extension by itself (.md), or via the --type <type> option (--type md):

# open a new Org file in the editor
nb add example.org

# open a new reStructuredText file in the editor
nb add --type rst

# open a new JavaScript file in the editor
nb add .js

Combining a type argument with piped clipboard content provides a very convenient way to save code snippets using a clipboard utility such as pbpaste, xclip, or pb:

# save the clipboard contents as a JavaScript file in the current notebook
pb | nb add .js

# save the clipboard contents as a Rust file in the "rust" notebook
# using the shortcut alias `nb a`
pb | nb a rust: .rs

# save the clipboard contents as a Haskell file named "example.hs" in the
# "snippets" notebook using the shortcut alias `nb +`
pb | nb + snippets: example.hs

Use nb show and nb browse to view code snippets with automatic syntax highlighting and use nb edit to open in your editor.

The clip plugin can also be used to create notes from clipboard content.

Piping, --title <title>, --tags <tag-list>, --content <content>, and content passed in an argument can be combined as needed to create notes with content from multiple input methods and sources using a single command:

❯ pb | nb add "Argument content." \
    --title   "Sample Title"      \
    --tags    tag1,tag2           \
    --content "Option content."
Added: [12] sample_title.md "Sample Title"

❯ nb show 12 --print
# Sample Title

#tag1 #tag2

Argument content.

Option content.

Clipboard content.

For a full list of options available for nb add, run nb help add.

Password-Protected Encrypted Notes and Bookmarks

Password-protected notes and bookmarks are created with the -e / --encrypt flag and encrypted with AES-256 using OpenSSL by default. GPG is also supported and can be configured with nb set encryption_tool.

Each protected note and bookmark is encrypted individually with its own password. When an encrypted item is viewed, edited, or opened, nb will simply prompt for the item's password before proceeding. After an item is edited, nb automatically re-encrypts it and saves the new version.

Encrypted notes can be decrypted using the OpenSSL and GPG command line tools directly, so you aren't dependent on nb to decrypt your files.

Shortcut Aliases: nb a, nb +

nb includes shortcuts for many commands, including nb a and nb + for nb add:

# create a new note in your text editor
nb a

# create a new note with the filename "example.md"
nb a example.md

# create a new note containing "This is a note."
nb + "This is a note."

# create a new note containing the clipboard contents with xclip
xclip -o | nb +

# create a new note in the notebook named "example"
nb example:a
Other Aliases: nb create, nb new

nb add can also be invoked with nb create and nb new for convenience:

# create a new note containing "Example note content."
nb new "Example note content."

# create a new note with the title "Example Note Title"
nb create --title "Example Note Title"
Adding with nb browse

Items can also be added within terminal and GUI web browsers using nb browse add / nb b a:

❯ nb browse add
❯nb · home : +

[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]

[add]

Pass a filename, relative path, and / or notebook name to create a new note at that location:

# open the add form in the browser to create the file "file.md" in the folder "example"
nb browse add "example/file.md"

nb browse add includes options for quickly pre-populating new notes with content:

❯ nb browse add --title "Example Title" --content "Example content." --tags tag1,tag2
❯nb · home : +

[# Example Title                                      ]
[                                                     ]
[#tag1 #tag2                                          ]
[                                                     ]
[Example content.                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]
[                                                     ]

[add]

nb browse add can also be opened with nb add --browse / nb a -b.

For more information, see Browsing.

Listing & Filtering

↑ Β· nb ls, nb list, nb browse

To list notes and notebooks, run nb ls (shortcut alias: nb):

nb ls

Notebooks are listed above the line, with the current notebook highlighted and/or underlined, depending on terminal capabilities. nb ls also includes a footer with example commands for easy reference. The notebook header and command footer can be configured or hidden with nb set header and nb set footer.

❯ nb ls
home
----
[3] example.md Β· "Example content."
[2] sample.md Β· "Sample content."
[1] demo.md Β· "- Demo list item one."

Notes from the current notebook are listed in the order they were last modified. By default, each note is listed with its id, filename, and an excerpt from the first line of the note. When a note has a title, the title is displayed instead of the filename and first line.

Markdown titles can be defined within a note using either Markdown h1 style or YAML front matter:

# Example Title
Sample Title
============
---
title: Demo Title
---

Org and LaTeX titles are recognized in .org and .latex files:

#+TITLE: Example Org Title
\title{Example LaTeX Title}

Once defined, titles are displayed in place of the filename and first line in the output of nb ls:

❯ nb ls
home
----
[3] Example Title
[2] Sample Title
[1] Demo Title

Pass an id, filename, or title to view the listing for that note:

❯ nb ls Sample\ Title
[2] Sample Title

❯ nb ls 3
[3] Example Title

If there is no exact match, nb will list items with titles and filenames that fuzzy match the query:

❯ nb ls exa
[3] Example Title

❯ nb ls ample
[3] Example Title
[2] Sample Title

Multiple words act like an OR filter, listing any titles or filenames that match any of the words:

❯ nb ls example demo
[3] Example Title
[1] Demo Title

When multiple words are quoted, filter titles and filenames for that phrase:

❯ nb ls "example title"
[3] Example Title

For full text search, see Search.

To view excerpts of notes, use the --excerpt or -e option, which optionally accepts a length:

❯ nb ls 3 --excerpt
[3] Example Title
-----------------
# Example Title

This is an example excerpt.

❯ nb ls 3 -e 8
[3] Example Title
-----------------
# Example Title

This is an example excerpt.

More example content:
- one
- two
- three

Several classes of file types are represented with emoji indicators to make them easily identifiable in lists. For example, bookmarks and encrypted notes are listed with πŸ”– and πŸ”’:

❯ nb ls
home
----
[4] Example Note
[3] πŸ”’ encrypted-note.md.enc
[2] πŸ”– Example Bookmark (example.com)
[1] πŸ”– πŸ”’ encrypted.bookmark.md.enc

File types include:

 πŸ”‰  Audio
 πŸ“–  Book
 πŸ”–  Bookmark
 πŸ”’  Encrypted
 πŸ“‚  Folder
 πŸŒ„  Image
 πŸ“„  PDF, Word, or Open Office document
 πŸ“Ή  Video

By default, items are listed starting with the most recently modified. To reverse the order, use the -r or --reverse flag:

❯ nb ls
home
----
[2] Todos
[3] Example Title
[1] Ideas

❯ nb ls --reverse
[1] Ideas
[3] Example Title
[2] Todos

Notes can be sorted with the -s / --sort flag, which can be combined with -r / --reverse:

❯ nb ls
home
----
[2] Sample Title
[3] Example Title
[1] Demo Title

❯ nb ls --sort
[1] Demo Title
[2] Sample Title
[3] Example Title

❯ nb ls --sort --reverse
[3] Example Title
[2] Sample Title
[1] Demo Title

nb with no subcommand behaves like an alias for nb ls, so the examples above can be run without the ls:

❯ nb
home
----
[2] Sample Title
[3] Example Title
[1] Demo Title

❯ nb example
[3] Example Title

❯ nb 3 --excerpt
[3] Example Title
-----------------
# Example Title

This is an example excerpt.

❯ nb 3 -e 8
[3] Example Title
-----------------
# Example Title

This is an example excerpt.

More example content:
- one
- two
- three

❯ nb --sort
[1] Demo Title
[2] Sample Title
[3] Example Title

❯ nb --sort --reverse
[3] Example Title
[2] Sample Title
[1] Demo Title

Short options can be combined for brevity:

# equivalent to `nb --sort --reverse --excerpt 2` and `nb -s -r -e 2`:
❯ nb -sre 2
[3] Example Title
-----------------
# Example Title

[2] Sample Title
----------------
Sample Title
============
[1] Demo Title
--------------
---
title: Demo Title

nb and nb ls display the 15 most recently modified items. The default limit can be changed with nb set limit <number>. To list a different number of items on a per-command basis, use the -n <limit>, --limit <limit>, --<limit>, -a, and --all flags:

❯ nb -n 1
home
----
[5] Example Five
4 omitted. 5 total.

❯ nb --limit 2
home
----
[5] Example Five
[4] Example Four
3 omitted. 5 total.

❯ nb --3
home
----
[5] Example Five
[4] Example Four
[3] Example Three
2 omitted. 5 total.

❯ nb --all
home
----
[5] Example Five
[4] Example Four
[3] Example Three
[2] Example Two
[1] Example One

Lists can be paginated with -p <number> / --page <number>, which paginates by the value of nb set limit by default, or the value of -n <limit>, --limit <limit>, or --<limit> when present:

❯ nb
home
----
[6] Example Six
[5] Example Five
[4] Example Four
[3] Example Three
[2] Example Two
[1] Example One

❯ nb set limit 3
NB_LIMIT set to 3

❯ nb --page 1
[6] Example Six
[5] Example Five
[4] Example Four

❯ nb -p 2
[3] Example Three
[2] Example Two
[1] Example One

❯ nb -p 2 --limit 2
[4] Example Four
[3] Example Three

❯ nb -p 3 --2
[2] Example Two
[1] Example One

nb ls is a combination of nb notebooks and nb list in one view and accepts the same arguments as nb list, which lists only notes without the notebook list and with no limit by default:

❯ nb list
[100] Example One Hundred
[99]  Example Ninety-Nine
[98]  Example Ninety-Eight
... lists all notes ...
[2]   Example Two
[1]   Example One

For more information about options for listing notes, run nb help ls and nb help list.

Listing with browse

Items can be listed within terminal and GUI web browsers using nb browse / nb b:

❯ nb browse example:sample/demo/
❯nb · example : sample / demo / +

search: [                    ]

[example:sample/demo/7] Title Seven
[example:sample/demo/6] Title Six
[example:sample/demo/5] Title Five
[example:sample/demo/4] Title Four
[example:sample/demo/3] Title Three

next ❯

For more information, see Browsing.

Editing

↑ Β· nb edit, nb browse edit

You can edit an item in your editor with nb edit (shortcut: nb e):

# edit note by id
nb edit 3

# edit note by filename
nb edit example.md

# edit note by title
nb edit "A Document Title"

# edit note 12 in the notebook named "example"
nb edit example:12

# edit note 12 in the notebook named "example", alternative
nb example:12 edit

# edit note 12 in the notebook named "example", alternative
nb example:edit 12

edit and other subcommands that take an identifier can be called with the identifier and subcommand name reversed:

# edit note by id
nb 3 edit

nb edit can also receive piped content, which it appends to the specified note without opening the editor:

echo "Content to append." | nb edit 1

Content can be passed with the --content <content> option, which also appends the content without opening the editor:

nb edit 1 --content "Content to append."

Use the --overwrite option to overwrite existing file content and the --prepend option to prepend the new content before existing content.

When content is piped or specified with --content <content>, use the --edit flag to open the file in the editor before the change is committed.

Editing Encrypted Notes

When a note is encrypted, nb edit prompts you for the note password, opens the unencrypted content in your editor, and then automatically reencrypts the note when you are done editing.

Shortcut Alias: nb e

nb edit can be called by the shortcut alias, nb e:

# edit note by id
nb e 3

# edit note by filename
nb e example.md

# edit note by title
nb e "A Document Title"

# edit note by id, alternative
nb 3 e

# edit note 12 in the notebook named "example"
nb e example:12

# edit note 12 in the notebook named "example", alternative
nb example:12 e

# edit note 12 in the notebook named "example", alternative
nb example:e 12

For nb edit help information, run nb help edit.

Editing with browse

Items can be edited within terminal and GUI web browsers using nb browse edit / nb b e:

❯ nb browse edit text:formats/markdown/123
❯nb Β· text : formats / markdown / 123 Β· ↓ Β· editing Β· - | +

[# Daring Fireball: Markdown (daringfireball.net)         ]
[                                                         ]
[<https://daringfireball.net/projects/markdown/>          ]
[                                                         ]
[## Related                                               ]
[                                                         ]
[- <https://en.wikipedia.org/wiki/Markdown>               ]
[                                                         ]
[## Comments                                              ]
[                                                         ]
[See also:                                                ]
[                                                         ]
[- [[text:formats/org]]                                   ]
[- [[cli:apps/nb]]                                        ]
[                                                         ]
[## Tags                                                  ]
[                                                         ]

[save] Β·Β last: 2021-01-01 01:00:00

For more information, see browse edit and Browsing.

Viewing

↑ Β· nb show, nb browse, nb open, nb peek

Notes and other items can be viewed using nb show (shortcut: nb s):

# show note by id
nb show 3

# show note by filename
nb show example.md

# show note by title
nb show "A Document Title"

# show note by id, alternative
nb 3 show

# show note 12 in the notebook named "example"
nb show example:12

# show note 12 in the notebook named "example", alternative
nb example:12 show

# show note 12 in the notebook named "example", alternative
nb example:show 12

By default, nb show opens notes in less, with syntax highlighting if bat, highlight, or Pygments is installed. You can navigate in less using the following keys:

Key               Function
---               --------
mouse scroll      Scroll up or down
arrow up or down  Scroll one line up or down
f                 Jump forward one window
b                 Jump back one window
d                 Jump down one half window
u                 Jump up one half window
/<query>          Search for <query>
n                 Jump to next <query> match
q                 Quit

If less scrolling isn't working in iTerm2, go to "Settings" -> "Advanced" -> "Scroll wheel sends arrow keys when in alternate screen mode" and change it to "Yes". More Info

Use the -p / --print option to print to standard output with syntax highlighting:

❯ nb show 123 --print
# Example Title

Example content:

- one
- two
- three

Use nb show --print --no-color to print without syntax highlighting.

When Pandoc is available, use the -r / --render option to render the note to HTML and open it in your terminal browser:

nb show example.md --render
# opens example.md as an HTML page in w3m, links, or lynx

nb show also supports previewing other file types in the terminal, depending on the tools available in the environment. Supported file types and tools include:

When using nb show with other file types or if the above tools are not available, nb show opens files in your system's preferred application for each type.

nb show also provides options for querying information about an item. For example, use the --added / -a and --updated / -u flags to print the date and time that an item was added or updated:

❯ nb show 2 --added
2020-01-01 01:01:00 -0700

❯ nb show 2 --updated
2020-02-02 02:02:00 -0700

nb show is primarily intended for viewing items within the terminal. To view a file in the system's preferred GUI application, use nb open. To browse rendered items in terminal and GUI web browsers, use nb browse.

For full nb show usage information, run nb help show.

Shortcut Alias: nb s

nb show can be called using the shortcut alias nb s:

# show note by id
nb s 3

# show note by filename
nb s example.md

# show note by title
nb s "A Document Title"

# show note by id, alternative
nb 3 s

# show note 12 in the notebook named "example"
nb s example:12

# show note 12 in the notebook named "example", alternative
nb example:12 s

# show note 12 in the notebook named "example", alternative
nb example:s 12
Alias: nb view

nb show can also be invoked with nb view for convenience:

# show note by id
nb view 3

# show note by filename
nb view example.md

# show note by title
nb view "A Document Title"

# show note by id, alternative
nb 3 view
Viewing with browse

Items can be viewed within terminal and GUI web browsers using nb browse / nb b:

❯ nb browse text:formats/markdown/123
❯nb Β· text : formats / markdown / 123 Β· ↓ Β· edit | +
Daring Fireball: Markdown (daringfireball.net)

https://daringfireball.net/projects/markdown/

Related

  β€’ https://en.wikipedia.org/wiki/Markdown

Comments

See also:

  β€’ [[text:formats/org]]
  β€’ [[cli:apps/nb]]

Tags

#markup #plain-text

Content

Daring Fireball: Markdown

Download

Markdown 1.0.1 (18 KB) — 17 Dec 2004

Introduction

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows
you to write using an easy-to-read, easy-to-write plain text format, then
convert it to structurally valid XHTML (or HTML).

For more information, see Browsing.

Deleting

↑ Β· nb delete, nb browse delete

To delete one or more notes, pass any number of ids, filenames, titles, and other selectors to nb delete (shortcuts: nb d, nb -):

# delete item by id
nb delete 3

# delete item by filename
nb delete example.md

# delete item by title
nb delete "A Document Title"

# delete item by id, alternative
nb 3 delete

# delete item 12 in the notebook named "example"
nb delete example:12

# delete item 12 in the notebook named "example", alternative
nb example:12 delete

# delete item 12 in the notebook named "example", alternative
nb example:delete 12

# delete item 345 in the folder named "example"
nb delete example/345

# delete items with the ids 89, 56, and 21
nb delete 89 56 21

By default, nb delete will display a confirmation prompt. To skip, use the --force / -f option:

nb delete 3 --force
Shortcut Aliases: nb d, nb -

nb delete has the aliases nb d and nb -:

# delete note by id
nb d 3

# delete note by filename
nb d example.md

# delete note by title
nb - "A Document Title"

# delete note by id, alternative
nb 3 d

# delete note 12 in the notebook named "example"
nb - example:12

# delete note 12 in the notebook named "example", alternative
nb example:12 d

# delete note 12 in the notebook named "example", alternative
nb example:d 12

For nb delete help information, run nb help delete.

Deleting with nb browse

Items can be deleted within terminal and GUI web browsers using nb browse delete / nb b d:

❯ nb browse delete example:4
❯nb Β· example : 4 Β· ↓ Β· edit Β· - | +

              deleting

[4] example_file.md "Example Title"

              [delete]
Β 

For more information, see Browsing.

πŸ”– Bookmarks

↑ Β· nb <url>, nb browse, nb bookmark, nb open, nb peek, nb show

nb includes a bookmarking system to conveniently create, annotate, view, search, browse, and manage collections of bookmarks.

nb bookmarks

Bookmarks in nb are stored as simple structured Markdown files containing information extracted from the bookmarked pages.

To create a new bookmark, pass a URL as the first argument to nb:

nb https://example.com

nb automatically generates a bookmark using information from the page:

# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

nb embeds the page content in the bookmark, making it available for full text search with nb search and locally-served, distraction-free reading and browsing with nb browse. When Pandoc is installed, the HTML page content is converted to Markdown. When readability-cli is installed, markup is cleaned up to focus on content.

In addition to caching the page content, you can also include a quote from the page in a ## Quote section using the -q <quote> / --quote <quote> option:

nb https://example.com --quote "Example quote line one.

Example quote line two."
# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Quote

> Example quote line one.
>
> Example quote line two.

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

Add a comment in a ## Comment section using the -c <comment> / --comment <comment> option:

nb https://example.com --comment "Example comment."
# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Comment

Example comment.

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

Add related URLs and linked selectors to a ## Related section using the -r (<url> | <selector>) / --related (<url> | <selector>) option:

nb https://example.com --related example:123 -r https://example.com
# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Related

- [[sample:123]]
- <https://example.net>

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

Bookmarks can be tagged using the -t <tag1>,<tag2>... / --tags <tag1>,<tag2>... option. Tags are converted into #hashtags and added to a ## Tags section:

nb https://example.com --tags tag1,tag2
# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Tags

#tag1 #tag2

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

Search for tagged bookmarks with nb search / nb q:

nb search --tag tag1

nb q -t tag1

nb q \#tag1

nb search / nb q automatically searches archived page content:

❯ nb q "example query"
[10] πŸ”– example.bookmark.md "Example Bookmark (example.com)"
------------------------------------------------------------
5:Lorem ipsum example query.

Bookmarks can also be encrypted:

# create a new password-protected, encrypted bookmark
nb https://example.com --encrypt

Encrypted bookmarks require a password before they can be viewed or opened.

Listing and Filtering Bookmarks

nb bookmark lists

Bookmarks are included in nb, nb ls, nb list, and nb browse along with items of other types. nb bookmark and nb bookmark list can be used to list and filter only bookmarks:

❯ nb bookmark
Add: nb <url> Help: nb help bookmark
------------------------------------
[3] πŸ”– πŸ”’ example.bookmark.md.enc
[2] πŸ”– Bookmark Two (example.com)
[1] πŸ”– Bookmark One (example.com)

❯ nb bookmark list two
[2] πŸ”– Bookmark Two (example.com)

Bookmarks are also included in nb, nb ls, and nb list:

❯ nb
home
----
[7] πŸ”– Bookmark Three (example.com)
[6] Example Note
[5] πŸ”– Bookmark Two (example.net)
[4] Sample Note
[3] πŸ”– πŸ”’ example-encrypted.bookmark.md.enc
[2] Demo Note
[1] πŸ”– Bookmark One (example.com)

Use the --type <type> / --<type> option as a filter to display only bookmarks:

❯ nb --type bookmark
[7] πŸ”– Bookmark Three (example.com)
[5] πŸ”– Bookmark Two (example.net)
[3] πŸ”– πŸ”’ example-encrypted.bookmark.md.enc
[1] πŸ”– Bookmark One (example.com)

❯ nb --bookmark
[7] πŸ”– Bookmark Three (example.com)
[5] πŸ”– Bookmark Two (example.net)
[3] πŸ”– πŸ”’ example-encrypted.bookmark.md.enc
[1] πŸ”– Bookmark One (example.com)

nb saves the domain in the title, making it easy to filter by domain using any list subcommands:

❯ nb example.com
[7] πŸ”– Bookmark Three (example.com)
[1] πŸ”– Bookmark One (example.com)

For more listing options, see nb help ls, nb help list, and nb help bookmark.

Shortcut Aliases: nb bk, nb bm

nb bookmark can also be used with the aliases nb bk and nb bm:

❯ nb bk
Add: nb <url> Help: nb help bookmark
------------------------------------
[7] πŸ”– Bookmark Three (example.com)
[5] πŸ”– Bookmark Two (example.net)
[3] πŸ”– πŸ”’ example-encrypted.bookmark.md.enc
[1] πŸ”– Bookmark One (example.com)

❯ nb bm example.net
[5] πŸ”– Bookmark Two (example.net)

Viewing Bookmarks

↑ Β· nb browse, nb open, nb peek, nb show

nb provides multiple ways to view bookmark files, bookmarked content, and bookmarked URLs.

Use nb browse (shortcut: nb b) to browse bookmarks with cached content, [[wiki-style links]], linked #tags, and external links:

❯ nb browse text:formats/markdown/123
❯nb Β· text : formats / markdown / 123 Β· ↓ Β· edit | +
Daring Fireball: Markdown (daringfireball.net)

https://daringfireball.net/projects/markdown/

Related

  β€’ https://en.wikipedia.org/wiki/Markdown

Comments

See also:

  β€’ [[text:formats/org]]
  β€’ [[cli:apps/nb]]

Tags

#markup #plain-text

Content

Daring Fireball: Markdown

Download

Markdown 1.0.1 (18 KB) — 17 Dec 2004

Introduction

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows
you to write using an easy-to-read, easy-to-write plain text format, then
convert it to structurally valid XHTML (or HTML).

For more information, see Browsing.

nb open (shortcut: nb o) opens the bookmarked URL in your system's primary web browser:

# open bookmark by id
nb open 3

# open bookmark 12 in the notebook named "example"
nb open example:12

# open bookmark 12 in the notebook named "example", alternative
nb example:12 open

# open bookmark 12 in the notebook named "example", alternative
nb example:open 12

N.B. To use nb open with WSL, install wslu.

nb peek (shortcut: nb p, alias: nb preview) opens the bookmarked URL in your terminal web browser, such as w3m, Links, or Lynx:

# peek bookmark by id
nb peek 3

# peek bookmark 12 in the notebook named "example"
nb peek example:12

# peek bookmark 12 in the notebook named "example", alternative
nb example:12 peek

# peek bookmark 12 in the notebook named "example", alternative
nb example:peek 12

nb open and nb peek work seamlessly with encrypted bookmarks. nb simply prompts you for the bookmark's password.

nb open and nb peek automatically check whether the URL is still valid. If the page has been removed, nb can check the Internet Archive Wayback Machine for an archived copy.

The preferred terminal web browser can be set using the $BROWSER environment variable, assigned in ~/.bashrc, ~/.zshrc, or similar:

export BROWSER=lynx

When $BROWSER is not set, nb looks for w3m, links, and lynx and uses the first one it finds.

$BROWSER can also be used to easy specify the terminal browser for an individual command:

❯ BROWSER=links nb 12 peek
# opens the URL from bookmark 12 in links

❯ BROWSER=w3m nb 12 peek
# opens the URL from bookmark 12 in w3m

nb show and nb edit can also be used to view and edit bookmark files, which include the cached page converted to Markdown.

nb show <id> --render / nb show <id> -r displays the bookmark file converted to HTML in the terminal web browser, including all bookmark fields and the cached page content, providing a cleaned-up, distraction-free, locally-served view of the page content along with all of your notes.

Shortcut Aliases: nb o and nb p

nb open and nb peek can also be used with the shortcut aliases nb o and nb p:

# open bookmark by id
nb o 3

# open bookmark 12 in the notebook named "example"
nb o example:12

# open bookmark 12 in the notebook named "example", alternative
nb example:12 o

# peek bookmark by id
nb p 3

# peek bookmark 12 in the notebook named "example"
nb p example:12

# peek bookmark 12 in the notebook named "example", alternative
nb example:12 p

Bookmark File Format

Bookmarks are identified by a .bookmark.md file extension. The bookmark URL is the first URL in the file within < and > characters. To create a minimally valid bookmark file with nb add:

nb add example.bookmark.md --content "<https://example.com>"

For a full overview, see nb Markdown Bookmark File Format.

bookmark -- A command line tool for managing bookmarks.

nb includes bookmark, a full-featured command line interface for creating, viewing, searching, and editing bookmarks.

bookmark is a shortcut for the nb bookmark subcommand, accepting all of the same subcommands and options with identical behavior.

Bookmark a page:

❯ bookmark https://example.com --tags tag1,tag2
Added: [3] πŸ”– 20200101000000.bookmark.md "Example Title (example.com)"

List and filter bookmarks with bookmark and bookmark list:

❯ bookmark
Add: bookmark <url> Help: bookmark help
---------------------------------------
[3] πŸ”– πŸ”’ example.bookmark.md.enc
[2] πŸ”– Example Two (example.com)
[1] πŸ”– Example One (example.com)

❯ bookmark list two
[2] πŸ”– Example Two (example.com)

View a bookmark in your terminal web browser:

bookmark peek 2

Open a bookmark in your system's primary web browser:

bookmark open 2

Perform a full text search of bookmarks and archived page content:

❯ bookmark search "example query"
[10] πŸ”– example.bookmark.md "Example Bookmark (example.com)"
------------------------------------------------------------
5:Lorem ipsum example query.

See bookmark help for more information.

βœ… Todos

↑ Β· nb do, nb tasks, nb todo, nb undo

Use nb todo (shortcut: nb t) to create, list, and update todos. nb todos are structured Markdown documents referencing a single primary todo, with optional tasks.

Use nb todo add to create a new todo:

# create a new todo titled "Example todo one."
❯ nb todo add "Example todo one."
Added: [1] βœ”οΈ [ ] Example todo one.

❯ nb show 1 --print
# [ ] Example todo one.

Use the --due <date> option to add an optional due date in a ## Due section:

# create a new todo titled "Example todo two." with a due date of "2100-01-01"
❯ nb todo add "Example todo two." --due "2100-01-01"
Added: [2] βœ”οΈ [ ] Example todo two.

❯ nb show 2 --print
# [ ] Example todo two.

## Due

2100-01-01

Add an optional description with the --description <description> option:

❯ nb todo add "Example todo three." --description "Example description."
Added: [3] βœ”οΈ [ ] Example todo three.

❯ nb show 3 --print
# [ ] Example todo three.

## Description

Example description.

Todos can have tasks. Tasks added with one or more --task <task> options are represented as a markdown task list and placed in a ## Tasks section:

❯ nb todo add "Example todo seven." --task "Task one." --task "Task two." --task "Task three."
Added: [7] βœ”οΈ [ ] Example todo seven.

❯ nb show 7 --print
# [ ] Example todo seven.

## Tasks

- [ ] Task one.
- [ ] Task two.
- [ ] Task three.

Related URLs and linked selectors can be added to a ## Related field using the -r (<url> | <selector>) / --related (<url> | <selector>) option:

❯ nb todo add "Example todo four." --related example:123 -r https://example.com
Added: [4] βœ”οΈ [ ] Example todo four.

❯ nb show 4 --print
# [ ] Example todo four.

## Related

- [[example:123]]
- <https://example.com>

Tags can be added to todos with the --tags <tag1>,<tag2>... option:

❯ nb todo add "Example todo five." --tags tag1,tag2
Added: [5] βœ”οΈ [ ] Example todo five.

❯ nb show 5 --print
# [ ] Example todo five.

## Tags

#tag1 #tag2

Tags, links, and URLs can be browsed in terminal and GUI web browers with nb browse.

Listing Todos

List todos in with nb todos:

# list todos in the current notebook
❯ nb todos
[6] βœ”οΈ [ ] Example todo six.
[5] βœ… [x] Example todo five.
[4] βœ”οΈ [ ] Example todo four.
[3] βœ… [x] Example todo three.
[2] βœ… [x] Example todo two.
[1] βœ”οΈ [ ] Example todo one.

# list todos in the notebook named "sample"
❯ nb todos sample:
[sample:4] βœ… [x] Sample todo four.
[sample:3] βœ”οΈ [ ] Sample todo three.
[sample:2] βœ”οΈ [ ] Sample todo two.
[sample:1] βœ… [x] Sample todo one.

Open / undone todos can be listed with nb todos open:

# list open todos in the current notebook
❯ nb todos open
[6] βœ”οΈ [ ] Example todo six.
[4] βœ”οΈ [ ] Example todo four.
[1] βœ”οΈ [ ] Example todo one.

# list open todos in the notebook named "sample"
❯ nb tasks open sample:
[sample:3] βœ”οΈ [ ] Sample todo three.
[sample:2] βœ”οΈ [ ] Sample todo two.

Closed / done todos can be listed with nb todos closed:

# list closed todos in the current notebook
❯ nb todos closed
[5] βœ… [x] Example todo five.
[3] βœ… [x] Example todo three.
[2] βœ… [x] Example todo two.

# list closed todos in the notebook named "sample"
❯ nb tasks closed sample:
[sample:4] βœ… [x] Sample todo four.
[sample:1] βœ… [x] Sample todo one.

See nb help todo for more information.

do / undo

Mark a todo as done or closed with nb do:

# add a new todo titled "Example todo six."
❯ nb todo add "Example todo six."
Added: [6] βœ”οΈ [ ] Example todo six.

# mark todo 6 as done / closed
❯ nb do 6
Done: [6] βœ… [x] Example todo six.

Re-open a closed todo with nb undo:

# mark todo 6 as undone / open
❯ nb undo 6
Undone: [6] βœ”οΈ [ ] Example todo six.

See nb help do and nb help undo for more information.

βœ”οΈ Tasks

↑ Β· nb do, nb tasks, nb todo, nb undo

nb can list and update tasks in todos and other Markdown documents.

Tasks are defined as one or more Markdown list items starting with - [ ] to indicate an open task or - [x] to indicate a done / closed task:

- [ ] Example open task.
- [x] Example closed task.

List tasks in items, folders, and notebooks with nb tasks (shortcut: nb t), which lists both tasks and todos:

# list tasks in item 7
❯ nb tasks 7
[7] βœ”οΈ [ ] Example todo seven.
------------------------------
[7 1] [x] Task one.
[7 2] [x] Task two.
[7 3] [ ] Task three.

# list tasks and todos in the notebook named "example"
❯ nb tasks example:
[example:9] βœ”οΈ [ ] Example todo nine.
[example:8] βœ… [x] Example todo eight.
--------------------------------------
[example:8 1] [x] Task one.
[example:8 2] [x] Task two.

[example:6] βœ”οΈ [ ] Example todo six.
[example:4] Example Note Title
------------------------------
[example:4 1] [ ] Task one.
[example:4 2] [x] Task two.
[example:4 3] [ ] Task three.

[example:3] βœ”οΈ [ ] Example todo three.

Open / undone tasks can be listed with nb tasks open:

# list open tasks in item 7
❯ nb tasks open 7
[7] βœ”οΈ [ ] Example todo seven.
------------------------------
[7 3] [ ] Task three.

# list open tasks and todos in the notebook named "example"
❯ nb tasks open example:
[example:9] βœ”οΈ [ ] Example todo nine.
[example:6] βœ”οΈ [ ] Example todo six.
[example:4] Example Note Title
------------------------------
[example:4 1] [ ] Task one.
[example:4 3] [ ] Task three.

[example:3] βœ”οΈ [ ] Example todo three.

Closed / done tasks can be listed with nb tasks closed:

# list closed tasks in item 7
❯ nb tasks closed 7
[7] βœ”οΈ [ ] Example todo seven.
------------------------------
[7 1] [x] Task one.
[7 2] [x] Task two.

# list closed tasks and todos in the notebook named "example"
❯ nb tasks closed example:
[example:8] βœ… [x] Example todo eight.
--------------------------------------
[example:8 1] [x] Task one.
[example:8 2] [x] Task two.

[example:4] Example Note Title
------------------------------
[example:4 2] [x] Task two.

Tasks are identified by the item selector, followed by a space, then followed by the sequential number of the task in the file.

Use nb do to mark tasks as done / closed:

# list tasks in item 9
❯ nb tasks 9
[9] βœ”οΈ [ ] Eample todo nine.
----------------------------
[9 1] [ ] Task one.
[9 2] [ ] Task two.
[9 3] [ ] Task three.

# mark task 2 in item 9 as done / closed
❯ nb do 9 2
[9] βœ”οΈ [ ] Eample todo nine.
----------------------------
Done: [9 2] [x] Task two.

# list tasks in item 9
❯ nb tasks 9
[9] βœ”οΈ [ ] Eample todo nine.
----------------------------
[9 1] [ ] Task one.
[9 2] [x] Task two.
[9 3] [ ] Task three.

Undo a done / closed task with nb undo:

# mark task 2 in item 9 as undone / open
❯ nb undo 9 2
[9] βœ”οΈ [ ] Example todo nine.
-----------------------------
Undone: [9 2] [ ] Task two.

# list tasks in item 9
❯ nb tasks 9
[9] βœ”οΈ [ ] Example todo nine.
-----------------------------
[9 1] [ ] Task one.
[9 2] [ ] Task two.
[9 3] [ ] Task three.

See nb help tasks for more information.

🏷 #tagging

↑ Β· nb add, nb bookmark, nb browse, nb list, nb ls, nb search

nb recognizes #hashtags defined anywhere within a document. A hashtag is defined in nb as a # character followed by any number of letters, numbers, underscores, and dashes.

Notes and bookmarks can be tagged when they are created using the --tags <tag1>,<tag2>... option, which is available with nb add, nb <url>, nb browse add, nb bookmark, and nb todo. --tags takes a comma-separated list of tags, converts them to #hashtags, and adds them to the document.

Tags added to notes with nb add --tags are placed between the title and body text:

❯ nb add --title "Example Title" "Example note content." --tags tag1,tag2
# Example Title

#tag1 #tag2

Example note content.

Tags added to bookmarks with nb <url> --tags and nb bookmark <url> --tags are placed in a ## Tags section:

❯ nb https://example.com --tags tag1,tag2
# Example Title (example.com)

<https://example.com>

## Description

Example description.

## Tags

#tag1 #tag2

## Content

Example Title
=============

This domain is for use in illustrative examples in documents. You may
use this domain in literature without prior coordination or asking for
permission.

[More information\...](https://www.iana.org/domains/example)

Tags added to todos with nb todo add --tags are placed in a ## Tags section:

❯ nb todo add --tags tag1,tag2 "Example todo."
# [ ] Example todo.

## Tags

#tag1 #tag2

Use nb --tags, nb ls --tags, and nb list --tags to list the tags present in a notebook, folder, or item:

# list all tags found in items in the current notebook
nb --tags

# list all tags found in the folder named "example"
nb example/ --tags

# list all tags in the item with id 123 in the notebook named "sample"
nb sample:123 --tags

Tagged items can be searched with nb search / nb q:

# search for items tagged with "#tag1"
nb search --tag tag1

# search for items tagged with "#tag1", shortcut and short option
nb q -t tag1

# search for items tagged with "#tag1", shortcut and argument
nb q \#tag1

# searc