Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/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://github.com/xwmx/nb
archiving bash bookmark-manager bookmarks cli command-line git knowledge-base markdown note-taking notebook notes notes-app pandoc productivity shell sync vim vscode zettelkasten
Last synced: 11 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/xwmx/nb
- Owner: xwmx
- License: agpl-3.0
- Created: 2016-01-12T17:27:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T00:16:05.000Z (6 months ago)
- Last Synced: 2024-05-02T00:56:13.298Z (5 months ago)
- Topics: archiving, bash, bookmark-manager, bookmarks, cli, command-line, git, knowledge-base, markdown, note-taking, notebook, notes, notes-app, pandoc, productivity, shell, sync, vim, vscode, zettelkasten
- Language: Shell
- Homepage: https://xwmx.github.io/nb
- Size: 9.14 MB
- Stars: 6,311
- Watchers: 77
- Forks: 177
- Open Issues: 113
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-github-repos - 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. (Shell)
- awesome-note-taking - nb - A command line and local web note‑taking, bookmarking, archiving, and knowledge base application (Open Source / CLI)
- awesome-zettelkasten - nb
- awesome-cli-tui-software - xwmx/nb - CLI plain-text note-taking, bookmarking, and archiving with encryption, filtering and search, Git-backed versioning and syncing, Pandoc-backed conversion, and more in a single portable script. (<a name="data"></a>data)
- fucking-awesome-cli-apps - nb - A note‑taking, bookmarking, archiving, and knowledge base application. (Productivity / Note Taking and Lists)
- my-awesome - xwmx/nb - manager,bookmarks,cli,command-line,git,knowledge-base,markdown,note-taking,notebook,notes,notes-app,pandoc,productivity,shell,sync,vim,vscode,zettelkasten pushed_at:2024-09 star:6.6k fork:0.2k 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. (Shell)
- project-awesome - 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. (Shell)
- awesome-cli-apps - nb - A note‑taking, bookmarking, archiving, and knowledge base application. (Productivity / Note Taking and Lists)
- awesome-starred - 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. (vim)
- jimsghstars - 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. (Shell)
README
`nb` is a command line and local web
note‑taking, bookmarking, archiving,
and knowledge base application
with:- plain text data storage,
- [encryption](#password-protected-encrypted-notes-and-bookmarks),
- [filtering](#listing--filtering), [pinning](#-pinning), [#tagging](#-tagging), and [search](#-search),
- [Git](https://git-scm.com/)-backed [versioning](#-revision-history) and [syncing](#-git-sync),
- [Pandoc](https://pandoc.org/)-backed [conversion](#%EF%B8%8F-import--export),
- [[wiki-style linking]],
- terminal and GUI web [browsing](#-browsing),
- inline [images](#-images),
- [todos](#-todos) with [tasks](#%EF%B8%8F-tasks),
- global and local [notebooks](#-notebooks),
- organization with [folders](#-folders),
- customizable [color themes](#-color-themes),
- extensibility through [plugins](#-plugins),and more, in a single portable script.
`nb` creates notes in text-based formats like
[Markdown](https://en.wikipedia.org/wiki/Markdown),
[Org](https://orgmode.org/),
[LaTeX](https://www.latex-project.org/),
and [AsciiDoc](https://asciidoc.org/),
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, MSYS, and Cygwin.
[Optional dependencies](#optional) can be installed to enhance functionality,
but `nb` works great without them.
`nb` is also a powerful [bookmarking](#-bookmarks) system featuring:
- locally-served, text-centric, distraction-free bookmark [browsing](#-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](https://archive.org/web/) 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` uses [Git](https://git-scm.com/) 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` 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](#tests) shell script
that can be
installed, copied, or `curl`ed almost anywhere and just work,
using a strategy inspired by
[progressive enhancement](https://en.wikipedia.org/wiki/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
#### Dependencies
##### Required
- [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell))
- `nb` works perfectly with Zsh, fish, and any other shell
set as your primary login shell,
the system just needs to have Bash available on it.
- [Git](https://git-scm.com/)
- A text editor with command line support, such as:
- [Vim](https://en.wikipedia.org/wiki/Vim_\(text_editor\)),
- [Emacs](https://en.wikipedia.org/wiki/Emacs),
- [Visual Studio Code](https://code.visualstudio.com/),
- [Sublime Text](https://www.sublimetext.com/),
- [Helix](https://helix-editor.com/),
- [micro](https://github.com/zyedidia/micro),
- [nano](https://en.wikipedia.org/wiki/GNU_nano),
- [Atom](https://atom.io/),
- [TextMate](https://macromates.com/),
- [MacDown](https://macdown.uranusjr.com/),
- [some of these](https://github.com/topics/text-editor),
- [and many of these.](https://en.wikipedia.org/wiki/List_of_text_editors)##### 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:
- [`bat`](https://github.com/sharkdp/bat)
- [`ncat`](https://nmap.org/ncat/) or [`socat`](https://www.kali.org/tools/socat/)
- [`pandoc`](https://pandoc.org/)
- [`rg`](https://github.com/BurntSushi/ripgrep)
- [`tig`](https://github.com/jonas/tig)
- [`w3m`](https://en.wikipedia.org/wiki/W3m)Also supported for various enhancements:
[Ack](https://beyondgrep.com/),
[`afplay`](https://ss64.com/osx/afplay.html),
[`asciidoctor`](https://asciidoctor.org/),
[The Silver Searcher (`ag`)](https://github.com/ggreer/the_silver_searcher),
[`catimg`](https://github.com/posva/catimg),
[Chafa](https://github.com/hpjansson/chafa),
[Chromium](https://www.chromium.org) / [Chrome](https://www.google.com/chrome/),
[`eza`](https://github.com/eza-community/eza),
[`ffplay`](https://ffmpeg.org/ffplay.html),
[ImageMagick](https://imagemagick.org/),
[`glow`](https://github.com/charmbracelet/glow),
[GnuPG](https://en.wikipedia.org/wiki/GNU_Privacy_Guard),
[`highlight`](http://www.andre-simon.de/doku/highlight/en/highlight.php),
[`imgcat`](https://www.iterm2.com/documentation-images.html),
[`joshuto`](https://github.com/kamiyaa/joshuto),
[kitty's `icat` kitten](https://sw.kovidgoyal.net/kitty/kittens/icat.html),
[`lsd`](https://github.com/lsd-rs/lsd),
[Links](https://en.wikipedia.org/wiki/Links_(web_browser)),
[Lynx](https://en.wikipedia.org/wiki/Lynx_(web_browser)),
[`mdcat`](https://github.com/swsnr/mdcat),
[`mdless`](https://github.com/ttscoff/mdless),
[`mdv`](https://github.com/axiros/terminal_markdown_viewer),
[Midnight Commander (`mc`)](https://en.wikipedia.org/wiki/Midnight_Commander),
[`mpg123`](https://en.wikipedia.org/wiki/Mpg123),
[MPlayer](https://en.wikipedia.org/wiki/MPlayer),
[`ncat`](https://nmap.org/ncat/),
[`netcat`](https://netcat.sourceforge.net/),
[note-link-janitor](https://github.com/andymatuschak/note-link-janitor)
(via [plugin](https://github.com/xwmx/nb/blob/master/plugins/backlink.nb-plugin)),
[`pdftotext`](https://en.wikipedia.org/wiki/Pdftotext),
[Pygments](https://pygments.org/),
[Ranger](https://ranger.github.io/),
[readability-cli](https://gitlab.com/gardenappl/readability-cli),
[`rga` / ripgrep-all](https://github.com/phiresky/ripgrep-all),
[`sc-im`](https://github.com/andmarti1424/sc-im),
[`socat`](https://www.kali.org/tools/socat/),
[`termvisage`](https://github.com/AnonymouX47/termvisage),
[`termpdf.py`](https://github.com/dsanson/termpdf.py),
[Tidy-Viewer (`tv`)](https://github.com/alexhallam/tv),
[`timg`](https://github.com/hzeller/timg),
[vifm](https://vifm.info/),
[`viu`](https://github.com/atanunq/viu),
[VisiData](https://www.visidata.org/)#### macOS / Homebrew
```bash
brew install xwmx/taps/nb
```Installing `nb` with Homebrew also installs
the recommended dependencies above
and completion scripts for Bash, Zsh, and Fish.Install the latest development version from the repository with:
```bash
brew install xwmx/taps/nb --head
````nb` is also available in
[homebrew-core](https://github.com/Homebrew/homebrew-core).
Installing it together with the `bash` formula is recommended:```bash
brew install nb bash
```#### Ubuntu, Windows, and others
##### npm
```bash
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`](#env)
to install the optional dependencies.When `nb` is installed on Windows,
`socat` ([MSYS](https://packages.msys2.org/package/socat),
[Cygwin](https://cygwin.com/packages/summary/socat.html)) is recommended.*`nb` is also available under its original package name,
[notes.sh](https://www.npmjs.com/package/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:```bash
# 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`](#env) 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:```bash
# 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:```bash
sudo nb env install
```##### Make
To install with [Make](https://en.wikipedia.org/wiki/Make_(software)),
clone this repository, navigate to the clone's root directory, and run:```bash
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](https://github.com/bpkg/bpkg):
```bash
bpkg install xwmx/nb
```##### basher
To install with [basher](https://www.basher.it/):
```bash
basher 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](https://github.com/xwmx/nb/tree/master/etc).#### 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`](#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 ·
$
Variables ·
Specifications ·
TestsTo get started, simply run:
```bash
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](#global-and-local-notebooks).### 📝 Notes
#### Adding
↑ ·
nb add
,
nb browse add
Use [`nb add`](#add) (shortcuts: [`nb a`](#add), [`nb +`](#add))
to create new notes:```bash
# 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`](#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`](#editor).`nb` files are [Markdown](https://daringfireball.net/projects/markdown/)
files by default. The default file type can be changed to
whatever you like
using [`nb set default_extension`](#default_extension).[`nb add`](#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:```bash
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:```bash
❯ nb add "This is a note."
Added: [1] 20200101000000.md
```[`nb add `](#add) 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`](#add) uses the current datetime as
the filename.[`nb add`](#add) can also receive piped content, which behaves the same as
[`nb add `](#add):```bash
# 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 `](#add) option,
which also creates a new note without opening the editor:```bash
nb add --content "Note content."
```When content is piped,
specified with [`--content `](#add),
or passed as a string argument,
use the [`--edit`](#add) 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:```bash
❯ nb add --filename "example.md" -t "Example Title" -c "Example content."
Added: [9] example.md "Example Title"
```The [`-t `](#add) / [`--title `](#add) option also
sets the filename to the title,
lowercased with spaces and non-filename characters replaced with underscores:```bash
❯ nb add --title "Example Title" "Example content."
Added: [10] example_title.md "Example Title"
```Tags can be added with the [`--tags ,...`](#add) option, which
takes a comma separated list of tags,
converts them to [#hashtags](#-tagging),
and inserts them between the title and content:```bash
❯ 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](#-search) for tagged items with
[`nb search`](#search) / [`nb q`](#search):```bash
# 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 `](#add) option (`--type md`):```bash
# 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`](https://github.com/xwmx/pb):```bash
# 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`](#show) and [`nb browse`](#browse) to view code snippets
with automatic syntax highlighting and
use [`nb edit`](#edit) to open in your editor.The [`clip` plugin](#clip) can also be used to
create notes from clipboard content.Piping,
[`--title `](#add),
[`--tags `](#add),
[`--content `](#add),
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:```bash
❯ 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`](#add), run
[`nb help add`](#add).##### Password-Protected Encrypted Notes and Bookmarks
Password-protected notes and [bookmarks](#-bookmarks) are
created with the [`-e`](#add) / [`--encrypt`](#add) flag and
encrypted with AES-256 using OpenSSL by default.
GPG is also supported and can be configured with
[`nb set encryption_tool`](#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`](#add) and [`nb +`](#add) for [`nb add`](#add):```bash
# 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`](#add) can also be invoked with
[`nb create`](#add) and [`nb new`](#add) for convenience:```bash
# 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`](#browse) / [`nb b a`](#browse):```bash
❯ nb browse add
❯nb · home : +[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ][add]
```Pass a filename, relative path, and / or notebook name to
create a new note at that location:```bash
# 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`](#browse) includes options for quickly
pre-populating new notes with content:```bash
❯ nb browse add --title "Example Title" --content "Example content." --tags tag1,tag2
❯nb · home : +[# Example Title ]
[ ]
[#tag1 #tag2 ]
[ ]
[Example content. ]
[ ]
[ ]
[ ]
[ ]
[ ][add]
```[`nb browse add`](#browse) can also be opened with
[`nb add --browse`](#add) / [`nb a -b`](#add).For more information, see [Browsing](#-browsing).
#### Listing & Filtering
To list notes and notebooks, run [`nb ls`](#ls) (shortcut alias: `nb`):
Notebooks are listed above the line,
with the current notebook highlighted and/or underlined,
depending on terminal capabilities.
[`nb ls`](#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`](#header) and
[`nb set footer`](#footer).```bash
❯ 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](https://daringfireball.net/projects/markdown/syntax#header)
or [YAML front matter](#front-matter):```markdown
# Example Title
``````markdown
Sample Title
============
``````markdown
---
title: Demo Title
---
```[Org](https://orgmode.org/),
[LaTeX](https://www.latex-project.org/),
and [AsciiDoc](https://asciidoc.org/)
titles are recognized in `.org`,`.latex`, and `.asciidoc` / `.adoc` files:```text
#+title: Example Org Title
``````latex
\title{Example LaTeX Title}
``````asciidoc
= Example AsciiDoc Title
```Once defined, titles are displayed in place of the filename and first line
in the output of [`nb ls`](#ls):```bash
❯ 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:
```bash
❯ 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:```bash
❯ 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:```bash
❯ nb ls example demo
[3] Example Title
[1] Demo Title
```When multiple words are quoted, filter titles and filenames for that phrase:
```bash
❯ nb ls "example title"
[3] Example Title
```For full text search, see [Search](#-search).
To view excerpts of notes, use the [`--excerpt`](#ls) or [`-e`](#ls) option,
which optionally accepts a length:```bash
❯ nb ls 3 --excerpt
[3] Example Title
-----------------
# Example TitleThis is an example excerpt.
❯ nb ls 3 -e 8
[3] Example Title
-----------------
# Example TitleThis is an example excerpt.
More example content:
- one
- two
```Several classes of file types are represented with emoji
[indicators](#indicators) to make them easily identifiable in lists.
For example, bookmarks and encrypted notes are listed with `🔖` and `🔒`:```bash
❯ nb ls
home
----
[4] Example Note
[3] 🔒 encrypted-note.md.enc
[2] 🔖 Example Bookmark (example.com)
[1] 🔖 🔒 encrypted.bookmark.md.enc
```File types include:
```text
🔉 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`](#ls) or [`--reverse`](#ls) flag:```bash
❯ 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`](#ls) / [`--sort`](#ls) flag,
which can be combined with [`-r`](#ls) / [`--reverse`](#ls):```bash
❯ 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`](#ls),
so the examples above can be run without the `ls`:```bash
❯ nb
home
----
[2] Sample Title
[3] Example Title
[1] Demo Title❯ nb example
[3] Example Title❯ nb 3 --excerpt
[3] Example Title
-----------------
# Example TitleThis is an example excerpt.
❯ nb 3 -e 8
[3] Example Title
-----------------
# Example TitleThis is an example excerpt.
More example content:
- one
- two❯ 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:
```bash
# 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`](#ls) display the 15 most recently modified items.
The default limit can be changed with [`nb set limit `](#limit).
To list a different number of items on a per-command basis, use the
[`-n `](#ls),
[`--limit `](#ls),
[`--`](#ls),
[`-a`](#ls),
and [`--all`](#ls)
flags:```bash
❯ 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 `](#ls) / [`--page `](#ls),
which paginates by the value of [`nb set limit`](#limit) by
default, or the value of
[`-n `](#ls),
[`--limit `](#ls),
or [`--`](#ls)
when present:```bash
❯ 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
```List [#tagged](#tagging) items by passing `\#escaped` or `"#quoted"` hashtags
or tags specified with the [`--tags`](#ls) option. Multiple tags perform an
`AND` query:```bash
# list items in the current notebook tagged with "#tag1", escaped
nb \#tag1# list items in the "example" notebook tagged with "#tag2", quoted
nb example: "#tag2"# list items in all notebooks tagged with "#tag1", long option
nb \#tag1 --all# list items in the current notebook tagged with "#tag1" AND "#tag2"
nb \#tag1 "#tag2"# list items in all notebooks tagged with "#tag2" AND "#tag3", short option
nb --tags tag2,tag3 -a
```[`nb ls`](#ls) is a combination of
[`nb notebooks`](#notebooks) and [`nb list`](#list)
in one view and accepts the same arguments as [`nb list`](#list),
which lists only notes without the notebook list and with no limit by default:```bash
❯ 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`](#ls)
and
[`nb help list`](#list).##### Listing with `browse`
Items can be listed within terminal and GUI web browsers using
[`nb browse`](#browse) / [`nb b`](#browse):```bash
❯ 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 Threenext ❯
```For more information, see [Browsing](#-browsing).
#### Editing
You can edit an item in your editor with
[`nb edit`](#edit) (shortcut: [`nb e`](#edit)):```bash
# 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`](#edit) and other subcommands that take an identifier
can be called with the identifier and subcommand name reversed:```bash
# edit note by id
nb 3 edit
```[`nb edit`](#edit) can also receive piped content, which it
appends to the specified note without opening the editor:```bash
echo "Content to append." | nb edit 1
```Content can be passed with the [`--content `](#edit) option,
which also appends the content without opening the editor:```bash
nb edit 1 --content "Content to append."
```Use the [`--overwrite`](#edit) option to overwrite existing file content
and the [`--prepend`](#edit) option to prepend the new content before existing content.When content is piped or specified with [`--content `](#edit),
use the [`--edit`](#edit) flag to open the file in the editor
before the change is committed.##### Editing Encrypted Notes
When a note is encrypted,
[`nb edit`](#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`](#edit) can be called by the shortcut alias, [`nb e`](#edit):
```bash
# 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`](#edit) help information, run [`nb help edit`](#edit).
##### Editing with `browse`
Items can be edited within terminal and GUI web browsers using
[`nb browse edit`](#browse) / [`nb b e`](#browse):```bash
❯ nb browse edit text:formats/markdown/123
❯nb · text : formats / markdown / 123 · ↓ · editing · - | +[# Daring Fireball: Markdown (daringfireball.net) ]
[ ]
[ ]
[ ]
[## Related ]
[ ]
[- ]
[ ]
[## Comments ]
[ ]
[See also: ]
[ ]
[- [[text:formats/org]] ]
[- [[cli:apps/nb]] ]
[ ]
[## Tags ]
[ ][save] · last: 2021-01-01 01:00:00
```For more information, see
[`browse edit`](#browse-edit) and [Browsing](#-browsing).#### Viewing
↑ ·
nb show
,
nb browse
,
nb open
,
nb peek
Notes and other items can be viewed using
[`nb show`](#show) (shortcut: [`nb s`](#show)):```bash
# 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`](#show) opens notes in
[`less`](https://linux.die.net/man/1/less),
with syntax highlighting if
[`bat`](https://github.com/sharkdp/bat),
[`highlight`](http://www.andre-simon.de/doku/highlight/en/highlight.php),
or
[Pygments](https://pygments.org/)
is installed.
You can navigate in `less` using the following keys:```text
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
/ Search for
n Jump to next match
q Quit
```*If `less` scrolling isn't working in [iTerm2](https://www.iterm2.com/),
go to*
"Settings"
-> "Advanced"
-> "Scroll wheel sends arrow keys when in alternate screen mode"
*and change it to* "Yes".
*[More Info](https://stackoverflow.com/a/37610820)*Use the [`-p`](#show) / [`--print`](#show) option
to print to standard output with syntax highlighting:```bash
❯ nb show 123 --print
# Example TitleExample content:
- one
- two
- three
```Use [`nb show --print --no-color`](#show) to print without syntax highlighting.
When [Pandoc](https://pandoc.org/) is available,
use the [`-r`](#show) / [`--render`](#show) option to
render the note to HTML and open it in your terminal browser:```bash
nb show example.md --render
# opens example.md as an HTML page in w3m, links, or lynx
```[`nb show`](#show) also supports previewing other file types in the terminal,
depending on the tools available in the environment. To prefer specific tools
for certain file types, `nb` provides configuration variables that can be
set in your `~/.nbrc` file,
which can be opened in your editor with [`nb settings edit`](#settings).Supported file types and tools include:
- Markdown files ([`$NB_MARKDOWN_TOOL`](#nb_markdown_tool)):
- [`bat`](https://github.com/sharkdp/bat)
- [`glow`](https://github.com/charmbracelet/glow)
- [`mdcat`](https://github.com/swsnr/mdcat)
- [`mdless`](https://github.com/ttscoff/mdless)
- [`mdv`](https://github.com/axiros/terminal_markdown_viewer)
- PDF files:
- [`termpdf.py`](https://github.com/dsanson/termpdf.py)
with [kitty](https://sw.kovidgoyal.net/kitty/)
- [`pdftotext`](https://en.wikipedia.org/wiki/Pdftotext)
- Audio files ([`$NB_AUDIO_TOOL`](#nb_audio_tool)):
- [`mplayer`](https://en.wikipedia.org/wiki/MPlayer)
- [`afplay`](https://ss64.com/osx/afplay.html)
- [`mpg123`](https://en.wikipedia.org/wiki/Mpg123)
- [`ffplay`](https://ffmpeg.org/ffplay.html)
- [Images](#-images) ([`$NB_IMAGE_TOOL`](#nb_image_tool)):
- [`catimg`](https://github.com/posva/catimg)
- [Chafa](https://github.com/hpjansson/chafa)
- [ImageMagick](https://imagemagick.org/) with a terminal that
supports [sixels](https://en.wikipedia.org/wiki/Sixel)
- [`imgcat`](https://www.iterm2.com/documentation-images.html) with
[iTerm2](https://www.iterm2.com/)
- [kitty's `icat` kitten](https://sw.kovidgoyal.net/kitty/kittens/icat.html)
- [`termvisage`](https://github.com/AnonymouX47/termvisage)
- [`timg`](https://github.com/hzeller/timg)
- [`viu`](https://github.com/atanunq/viu)
- Folders, Directories, Notebooks ([`$NB_DIRECTORY_TOOL`](#nb_directory_tool)):
- [`eza`](https://github.com/eza-community/eza)
- [`joshuto`](https://github.com/kamiyaa/joshuto)
- [`lsd`](https://github.com/lsd-rs/lsd)
- [Midnight Commander (`mc`)](https://en.wikipedia.org/wiki/Midnight_Commander)
- [`ranger`](https://ranger.github.io/)
- [`vifm`](https://vifm.info/)
- Word Documents:
- [Pandoc](https://pandoc.org/) with
[`w3m`](https://en.wikipedia.org/wiki/W3m) or
[`links`](https://en.wikipedia.org/wiki/Links_(web_browser))
- Excel, CSV, TSV, and data files ([`$NB_DATA_TOOL`](#nb_data_tool)):
- [VisiData](https://www.visidata.org/)
- [`sc-im`](https://github.com/andmarti1424/sc-im)
- [Tidy-Viewer (`tv`)](https://github.com/alexhallam/tv)
- EPUB ebooks:
- [Pandoc](https://pandoc.org/) with
[`w3m`](https://en.wikipedia.org/wiki/W3m) or
[`links`](https://en.wikipedia.org/wiki/Links_(web_browser))When using [`nb show`](#show) with other file types or
if the above tools are not available,
[`nb show`](#show) opens files in
your system's preferred application for each type.[`nb show`](#show) also provides [options](#show) for
querying information about an item. For example, use the
[`--added`](#show) / [`-a`](#show) and [`--updated`](#show) / [`-u`](#show)
flags to print the date and time that an item was added or updated:```bash
❯ nb show 2 --added
2020-01-01 01:01:00 -0700❯ nb show 2 --updated
2020-02-02 02:02:00 -0700
```[`nb show`](#show) is primarily intended for viewing items within the terminal.
To view a file in the system's preferred GUI application, use
[`nb open`](#open).
To [browse](#-browsing) rendered items in terminal and GUI web browsers, use
[`nb browse`](#browse).For full [`nb show`](#show) usage information, run [`nb help show`](#show).
##### Shortcut Alias: `nb s`
[`nb show`](#show) can be called using the shortcut alias [`nb s`](#show):
```bash
# 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`](#show) can also be invoked with [`nb view`](#show) for convenience:
```bash
# 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`](#browse) / [`nb b`](#browse):```bash
❯ 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](#-browsing).
#### Deleting
↑ ·
nb delete
,
nb browse delete
To delete one or more notes, pass any number of
ids, filenames, titles, and other [selectors](#-selectors)
to [`nb delete`](#delete) (shortcuts: [`nb d`](#delete), [`nb -`](#delete)):```bash
# 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`](#delete) will display a confirmation prompt.
To skip, use the [`--force`](#delete) / [`-f`](#delete) option:```bash
nb delete 3 --force
```##### Shortcut Aliases: `nb d`, `nb -`
[`nb delete`](#delete) has the aliases [`nb d`](#delete) and [`nb -`](#delete):
```bash
# 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`](#delete) help information, run [`nb help delete`](#delete).
##### Deleting with `nb browse`
Items can be deleted within terminal and GUI web browsers using
[`nb browse delete`](#browse) / [`nb b d`](#browse):```bash
❯ nb browse delete example:4
❯nb · example : 4 · ↓ · edit · - | +deleting
[4] example_file.md "Example Title"
[delete]
```For more information, see [Browsing](#-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](#-browsing), and manage
collections of bookmarks.
Bookmarks in `nb` are stored as
[simple structured Markdown files](#nb-markdown-bookmark-file-format)
containing information extracted from the bookmarked pages.To create a new bookmark, pass a URL as the first argument to `nb`:
```bash
nb https://example.com
````nb` automatically generates a bookmark using information from the page:
```markdown
# Example Title (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](#-search) with [`nb search`](#search) and
locally-served, distraction-free [reading and browsing](#-browsing)
with [`nb browse`](#browse).
When [Pandoc](https://pandoc.org/) is installed,
the HTML page content is converted to Markdown.
When [readability-cli](https://gitlab.com/gardenappl/readability-cli)
is installed, markup is cleaned up to focus on content. When
[Chromium](https://www.chromium.org) or
[Chrome](https://www.google.com/chrome/) is installed,
JavaScript-dependent pages are rendered and the resulting markup is
saved.Many shells automatically escape special characters in URLs. If a
URL contains characters that are preventing it from being saved in full,
URLs can also be enclosed in quotes when passed to `nb`:```bash
nb "https://example.com#sample-anchor"
```In addition to caching the page content,
you can also include a quote from the page in a
[`## Quote`](#-quote) section
using the
[`-q `](#bookmark) / [`--quote `](#bookmark) option:```bash
nb https://example.com --quote "Example quote line one.Example quote line two."
```
```markdown
# Example Title (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`](#-comment) section using the
[`-c `](#bookmark) / [`--comment `](#bookmark) option:```bash
nb https://example.com --comment "Example comment."
```
```markdown
# Example Title (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](#-linking) [selectors](#-selectors)
to a [`## Related`](#-related) section using the
[`-r ( | )`](#bookmark) /
[`--related ( | )`](#bookmark)
option:```bash
nb https://example.com --related example:123 -r https://example.net
```
```markdown
# Example Title (example.com)## Description
Example description.
## Related
- [[example:123]]
-## 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 ,...`](#bookmark) /
[`--tags ,...`](#bookmark) option.
Tags are converted into [#hashtags](#-tagging) and
added to a [`## Tags`](#-tags) section:```bash
nb https://example.com --tags tag1,tag2
```
```markdown
# Example Title (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](#-search) for tagged bookmarks with
[`nb search`](#search) / [`nb q`](#search):```bash
nb search --tag tag1nb q -t tag1
nb q \#tag1
```[`nb search`](#search) / [`nb q`](#search)
automatically searches archived page content:```bash
❯ nb q "example query"
[10] 🔖 example.bookmark.md "Example Bookmark (example.com)"
------------------------------------------------------------
5:Lorem ipsum example query.
```Bookmarks can also be encrypted:
```bash
# 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
Bookmarks are included in
`nb`,
[`nb ls`](#ls),
[`nb list`](#list),
and [`nb browse`](#browse)
along with items of other types.
[`nb bookmark`](#bookmark) and [`nb bookmark list`](#bookmark) can be used to
list and filter only bookmarks:```bash
❯ nb bookmark
Add: nb 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`](#ls), and [`nb list`](#list):
```bash
❯ 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 `](#ls) / [`--`](#ls)
option as a filter to display only bookmarks:```bash
❯ 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:```bash
❯ nb example.com
[7] 🔖 Bookmark Three (example.com)
[1] 🔖 Bookmark One (example.com)
```For more listing options, see
[`nb help ls`](#ls),
[`nb help list`](#list),
and [`nb help bookmark`](#bookmark).##### Shortcut Aliases: `nb bk`, `nb bm`
[`nb bookmark`](#bookmark) can also be used with the aliases
[`nb bk`](#bookmark) and [`nb bm`](#bookmark):```bash
❯ nb bk
Add: nb 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`](#browse) (shortcut: [`nb b`](#browse))
to [browse](#-browsing) bookmarks with cached content,
[[wiki-style links]],
linked [#tags](#-tagging), and external links:```bash
❯ 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](#-browsing).
[`nb open`](#open) (shortcut: [`nb o`](#open)) opens the bookmarked URL in
your system's primary web browser:```bash
# 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`](#open) with
[WSL](https://docs.microsoft.com/en-us/windows/wsl/install),
install [wslu](https://github.com/wslutilities/wslu).*[`nb peek`](#peek) (shortcut: [`nb p`](#peek), alias: [`nb preview`](#peek))
opens the bookmarked URL in your terminal web browser,
such as
[w3m](https://en.wikipedia.org/wiki/W3m),
[Links](https://en.wikipedia.org/wiki/Links_(web_browser)), or
[Lynx](https://en.wikipedia.org/wiki/Lynx_(web_browser)):```bash
# 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`](#open) and [`nb peek`](#peek)
work seamlessly with encrypted bookmarks.
`nb` simply prompts you for the bookmark's password.[`nb open`](#open) and [`nb peek`](#peek)
automatically check whether the URL is still valid.
If the page has been removed, `nb` can check
the [Internet Archive Wayback Machine](https://archive.org/web/)
for an archived copy.The preferred terminal web browser can be set using
the `$BROWSER` environment variable,
assigned in `~/.bashrc`, `~/.zshrc`, or similar:```bash
export BROWSER=lynx
```When `$BROWSER` is not set, `nb` looks for
[`w3m`](https://en.wikipedia.org/wiki/W3m),
[`links`](https://en.wikipedia.org/wiki/Links_(web_browser)), and
[`lynx`](https://en.wikipedia.org/wiki/Lynx_(web_browser))
and uses the first one it finds.`$BROWSER` can also be used to easy specify the terminal browser for
an individual command:```bash
❯ 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`](#show) and [`nb edit`](#edit)
can also be used to view and edit bookmark files,
which include the cached page converted to Markdown.[`nb show --render`](#show) / [`nb show -r`](#show)
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`](#open) and [`nb peek`](#peek)
can also be used with the shortcut aliases
[`nb o`](#open) and [`nb p`](#peek):```bash
# 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`](#add):```bash
nb add example.bookmark.md --content ""
```For a full overview, see
[`nb` Markdown Bookmark File Format](#nb-markdown-bookmark-file-format).#### `bookmark` -- A command line tool for managing bookmarks.
`nb` includes [`bookmark`](#bookmark-help), a full-featured
command line interface for creating, viewing, searching, and editing bookmarks.[`bookmark`](#bookmark-help) is a shortcut for the
[`nb bookmark`](#bookmark) subcommand,
accepting all of the same subcommands and options with identical behavior.Bookmark a page:
```bash
❯ bookmark https://example.com --tags tag1,tag2
Added: [3] 🔖 20200101000000.bookmark.md "Example Title (example.com)"
```
List and filter bookmarks with
[`bookmark`](#bookmark) and [`bookmark list`](#bookmark):```bash
❯ bookmark
Add: bookmark 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:
```bash
bookmark peek 2
```Open a bookmark in your system's primary web browser:
```bash
bookmark open 2
```Perform a full text search of bookmarks and archived page content:
```bash
❯ bookmark search "example query"
[10] 🔖 example.bookmark.md "Example Bookmark (example.com)"
------------------------------------------------------------
5:Lorem ipsum example query.
```See [`bookmark help`](#bookmark-help) for more information.
### ✅ Todos
↑ ·
nb do
,
nb tasks
,
nb todo
,
nb undo
Use [`nb todo`](#todo) (shortcut: [`nb to`](#todo))
to create, list, and update todos.
`nb` todos are [structured Markdown documents](#nb-markdown-todo-file-format)
referencing a single primary todo,
with optional [tasks](#%EF%B8%8F-tasks).Use [`nb todo add`](#todo) to create a new todo:
```bash
# 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 `](#todo) option to add an optional due date in a
[`## Due`](#-due) section:```bash
# 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](#-description-1) with the
[`--description `](#todo)
option:```bash
❯ 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](#%EF%B8%8F-tasks).
Tasks added with one or more [`--task `](#todo) options
are represented as a markdown task list and placed in a
[`## Tasks`](#-tasks) section:```bash
❯ 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](#-linking) [selectors](#-selectors)
can be added to a [`## Related`](#-related-1) field using the
[`-r ( | )`](#todo) / [`--related ( | )`](#todo)
option:```bash
❯ 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]]
-
```[Tags](#-tagging) can be added to todos with the
[`--tags ,...`](#todo) option:```bash
❯ 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](#-tagging), [links](#-linking), and URLs can be
[browsed](#-browsing)
in terminal and GUI web browsers with [`nb browse`](#browse).#### Listing Todos
List todos in with [`nb todos`](#todo):
```bash
# 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`](#todo):
```bash
# 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`](#todo):
```bash
# 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`](#todo)
for more information.#### `do` / `undo`
Mark a todo as done or closed with [`nb do`](#do):
```bash
# 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`](#undo):
```bash
# mark todo 6 as undone / open
❯ nb undo 6
Undone: [6] ✔️ [ ] Example todo six.
```See
[`nb help do`](#do)
and
[`nb help undo`](#undo)
for more information.### ✔️ Tasks
↑ ·
nb do
,
nb tasks
,
nb todo
,
nb undo
`nb` can list and update tasks in [todos](#-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:```markdown
- [ ] Example open task.
- [x] Example closed task.
```List tasks in items, folders, and notebooks with
[`nb tasks`](#tasks) (shortcut: [`nb t`](#tasks)),
which lists both tasks and todos:```bash
# 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`](#tasks):
```bash
# 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`](#tasks):
```bash
# 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](#-selectors), followed by
a space, then followed by the sequential number of the task in the file.Use [`nb do`](#do) to mark tasks as done / closed:
```bash
# list tasks in item 9
❯ nb tasks 9
[9] ✔️ [ ] Example 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] ✔️ [ ] Example todo nine.
-----------------------------
Done: [9 2] [x] Task two.# list tasks in item 9
❯ nb tasks 9
[9] ✔️ [ ] Example todo nine.
-----------------------------
[9 1] [ ] Task one.
[9 2] [x] Task two.
[9 3] [ ] Task three.
```Undo a done / closed task with [`nb undo`](#undo):
```bash
# 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`](#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 ,...` option,
which is available with
[`nb add`](#add),
[`nb `](#nb-help),
[`nb browse add`](#browse),
[`nb bookmark`](#bookmark),
and
[`nb todo`](#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`](#add) are placed between the title
and body text:```bash
❯ nb add --title "Example Title" "Example note content." --tags tag1,tag2
``````markdown
# Example Title#tag1 #tag2
Example note content.
```Tags added to [bookmarks](#bookmarks) with
[`nb --tags`](#nb-help) and [`nb bookmark --tags`](#bookmark)
are placed in a [`## Tags`](#-tags) section:```bash
❯ nb https://example.com --tags tag1,tag2
``````markdown
# Example Title (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](#-todos) with
[`nb todo add --tags`](#todo)
are placed in a [`## Tags`](#-tags-1) section:```bash
❯ nb todo add --tags tag1,tag2 "Example todo."
``````markdown
# [ ] Example todo.## Tags
#tag1 #tag2
```Use [`nb --tags`](#nb-help), [`nb ls --tags`](#ls),
and [`nb list --tags`](#list)
to list the tags present in a notebook, folder, or item:```bash
# 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
```List tagged items by passing `\#escaped` or `"#quoted"` hashtags or tags
specified with the [`--tags`](#ls) option to [`nb`](#ls) / [`nb ls`](#ls):```bash
# list items in the current notebook tagged with "#tag1", escaped
nb \#tag1# list items in the "example" notebook tagged with "#tag2", quoted
nb example: "#tag2"# list items in all notebooks tagged with "#tag3", long option
nb --tags tag3 --all# list items in all notebooks tagged with "#tag3", short option
nb --tags tag3 -a
```Combine multiple tags to search for items containing all specified tags:
```bash
# list items in the current notebook tagged with "#tag1" AND "#tag2"
nb \#tag1 "#tag2"# list items in the current notebook tagged with "#tag2" AND "#tag3"
nb --tags tag2,tag3# list items in all notebooks tagged with "#tag1" AND "#tag2" AND "#tag3" AND "#tag4"
nb \#tag1 "#tag2" --tags tag3,tag4 --all
```Tagged items can be [searched](#-search) with
[`nb search`](#search) / [`nb q`](#search):```bash
# 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# search for items tagged with "#tag1", shortcut and argument, alternative
nb q "#tag1"# search for items tagged with "#tag1" AND "#tag2"
nb q --tag tag1 --tag tag2# search for items tagged with "#tag1" AND "#tag2", short options
nb q -t tag1 -t tag2# search for items tagged with "#tag1" AND "#tag2", arguments
nb q \#tag1 \#tag2# search for items tagged with "#tag1" AND "#tag2", tag list
nb q --tags tag1,tag2# search for items tagged with either "#tag1" OR "#tag2", options
nb q -t tag1 --or -t tag2# search for items tagged with either "#tag1" OR "#tag2", arguments
nb q \#tag1 --or \#tag2# search for items tagged with either "#tag1" OR "#tag2", single argument
nb q "#tag1|#tag2"# search for items tagged with "#tag1" AND "#tag2" AND "#tag3"
nb q -t tag1 --tags tag2,tag3# search for items tagged with "#tag1" OR "#tag2" OR "#tag3"
nb q -t tag1 --or --tags tag2,tag3# search for items tagged with "#tag1" OR "#tag2" OR "#tag3"
nb q \#tag1 --or -t tag2 --or "#tag3"
```Linked tags can be [browsed](#-browsing) with [`nb browse`](#browse),
providing another dimension of browsability in terminal and GUI web browsers,
complimenting [[wiki-style linking]].Tags in notes,
bookmarks,
files in text-based formats,
Word `.docx` documents,
and [Open Document](https://en.wikipedia.org/wiki/OpenDocument) `.odt` files
are rendered as links to the list of items in the notebook sharing that tag:```bash
❯nb · example : 321Example Title
#tag1 #tag2
Example content with link to [[Sample Title]].
More example content:
- one
- two
- three
```Use the [`-t `](#browse) / [`--tag `](#browse) option
to open [`nb browse`](#browse) to the list of
all items in the current notebook or a specified notebook or folder that
share a tag:```bash
# open to a list of items tagged with "#tag2" in the "example" notebook
❯ nb browse example: --tag tag2
❯nb · examplesearch: [#tag2 ]
[example:321] Example Title
[example:654] Sample Title
[example:789] Demo Title# shortcut alias and short option
❯ nb b example: -t tag2
❯nb · examplesearch: [#tag2 ]
[example:321] Example Title
[example:654] Sample Title
[example:789] Demo Title
```For more information about full-text search, see
[Search](#-search) and [`nb search`](#search).
For more information about browsing, see
[Browsing](#-browsing) and [`nb browse`](#browse).### 🔗 Linking
Notes,
bookmarks,
files in text-based formats,
Word `.docx` documents,
and [Open Document](https://en.wikipedia.org/wiki/OpenDocument) `.odt` files
can reference other items using
[[wiki-style links]],
making `nb` a powerful terminal-first platform for
[Zettelkasten](#-zettelkasten),
wiki-style knowledge mapping,
and other link-based note-taking methods.To add a link from a note or bookmark to another in the same notebook,
include the id, title, or relative path for the target item
within double square brackets anywhere in the linking document:```bash
# link to the item with id 123 in the root level of current notebook
[[123]]# link to the item titled "Example Title" in the root level of the current notebook
[[Example Title]]# link to the item with id 456 in the folder named "Sample Folder"
[[Sample Folder/456]]# link to the item titled "Demo Title" in the folder named "Sample Folder"
[[Sample Folder/Demo Title]]
```To link to an item in another notebook,
add the notebook name with a colon before the identifier:```bash
# link to the item with id 123 in the "sample" folder in the "example" notebook
[[example:sample/123]]# link to the item titled "Example Title" in the "demo" notebook
[[demo:Example Title]]# link to the item with filename "Example File.md" in the "sample" notebook
[[sample:Example File.md]]
```The text for a link can be specified after a pipe `|` character:
```bash
# render link to item 123 in the "example" notebook as [[Example Link Text]]
[[example:123|Example Link Text]]
```[[wiki-style links]] cooperate well with
[Org links](https://orgmode.org/guide/Hyperlinks.html),
which have a similar syntax,
providing a convenient option for linking collections of Org files.Linked items can be [browsed](#-browsing) with [`nb browse`](#browse).
For more information about identifying items, see [Selectors](#-selectors).
### 🌍 Browsing
Use [`nb browse`](#browse) (shortcut: [`nb b`](#browse)) to
browse, view, edit, and search linked notes, bookmarks, notebooks, folders,
and other items using terminal and GUI web browsers.
[`nb browse`](#browse) includes an embedded, terminal-first web application
that renders
[[wiki-style links]]
and
[#hashtags](#-tagging)
as internal links, enabling you to browse your notes and notebooks in web
browsers, including seamlessly browsing to and from the offsite links in
bookmarks and notes.```bash
❯ nb browse
❯nb · home : +search: [ ]
[home:6] 📌 Example Markdown Title
[home:12] 🔒 example-encrypted.md.enc
[home:11] 🔖 Example Bookmark (example.com)
[home:10] 🔖 🔒 example-encrypted.bookmark.md.enc
[home:9] Example .org Title
[home:8] 🌄 example-image.png
[home:7] 📄 example.pdf
[home:5] 🔉 example-audio.mp3
[home:4] Example LaTeX Title
[home:3] 📹 example-video.mp4
[home:2] example.md
[home:1] 📂 Example Folder
```Lists are displayed using the same format as `nb` and [`nb ls`](#ls),
including [pinned](#-pinning) items, with each list item linked.
Lists are automatically paginated to fit the height of the terminal window.```bash
❯ 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 Threenext ❯
```[`nb browse`](#browse) is designed to make it easy to navigate within
terminal web browsers using only keyboard commands,
while also supporting mouse interactions.
The [`nb browse`](#browse) interface includes links
to quickly jump to parent folders,
the current notebook,
and other notebooks.[`nb browse`](#browse) opens in
[w3m](https://en.wikipedia.org/wiki/W3m),
[Links](https://en.wikipedia.org/wiki/Links_\(web_browser\)),
or in the browser set in the `$BROWSER` environment variable.
Use [`nb browse --gui`](#browse) / [`nb b -g`](#browse) to
open in the system's primary [GUI web browser](#browse---gui).To open a specific item in [`nb browse`](#browse),
pass the [selector](#-selectors) for the item, folder, or notebook
to [`nb browse`](#browse):```bash
# open the item with id 42 in the folder named "sample" in the "example" notebook
❯ nb browse example:sample/42
❯nb · example : sample / 42 · ↓ · edit | +Example Title
#tag1 #tag2
Example content with link to [[Demo Title]].
More example content:
• one
• two
• three
```Items can also be browsed with
[`nb show --browse`](#show) / [`nb s -b`](#show),
which behaves identically.[`nb browse`](#browse) is particularly useful for [bookmarks](#-bookmarks).
Cached content is rendered in the web browser along with comments and notes.
Internal and external links are easily accessible directly in the terminal,
providing a convenient, distraction-free approach for browsing collections
of bookmarks.```bash
❯ 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).
```Notes, bookmarks, files in text-based formats, source code,
Word `.docx` documents, and
[Open Document](https://en.wikipedia.org/wiki/OpenDocument) `.odt`
files are converted into HTML and rendered in the browser. Use the down
arrow (`↓`) link to view or download the original file.#### `browse edit`
Items in text formats can be edited within terminal and GUI web browsers using
the `edit` link on the item page or by opening the item with
[`nb browse edit`](#browse) / [`nb b e`](#browse),
which automatically resizes the form to fit the current terminal window:```bash
❯ nb browse edit text:formats/markdown/123
❯nb · text : formats / markdown / 123 · ↓ · editing · - | +[# Daring Fireball: Markdown (daringfireball.net) ]
[ ]
[ ]
[ ]
[## Related ]
[ ]
[- ]
[ ]
[## Comments ]
[ ]
[See also: ]
[ ]
[- [[text:formats/org]] ]
[- [[cli:apps/nb]] ]
[ ]
[## Tags ]
[ ][save] · last: 2021-01-01 01:00:00
```Terminal web browsers provide different editing workflows.
[`w3m`](https://en.wikipedia.org/wiki/W3m) opens items in your `$EDITOR`,
then returns you back to the browser to save changes and continue browsing.
Edits in [`links`](https://en.wikipedia.org/wiki/Links_(web_browser))
are performed directly in the browser.Syntax highlighting, block selection, and other
[advanced editor features](#browse---gui-editing)
are available with [`nb browse --gui`](#browse).#### `browse add`
Add an item within the browser using the `+` link or
[`nb browse add`](#browse) / [`nb b a`](#browse).
Pass a notebook, folder, and / or filename selector to create a new note
in that location:```bash
❯ nb browse add text:formats/
❯nb · text : formats / +[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ][add]
```[`nb browse add`](#browse) includes options for quickly pre-populating
new notes with content:```bash
❯ nb browse add --title "Example Title" --content "Example content." --tags tag1,tag2
❯nb · home : +[# Example Title ]
[ ]
[#tag1 #tag2 ]
[ ]
[Example content. ]
[ ]
[ ]
[ ]
[ ]
[ ][add]
```#### `browse delete`
Use the `-` link on the [`nb browse edit`](#browse) page or
[`nb browse delete`](#browse) / [`nb b d`](#browse)
to delete an item:```bash
❯ nb browse delete example:4
❯nb · example : 4 · ↓ · edit · - | +deleting
[4] example_file.md "Example Title"
[delete]
```#### `browse` Search
[`nb browse`](#browse) includes a search field powered by
[`nb search`](#search)
that can be used to search the current notebook or folder.
Search queries are treated as command line arguments for
[`nb search`](#search),
providing the ability to perform `AND` and `OR` queries.
Use the
[`-q `](#browse) / [`--query `](#browse)
option to open [`nb browse`](#browse) to
the results page for a search:```bash
# open to a list of items containing "example" in the current notebook
❯ nb browse --query "example"
❯nb · homesearch: [example ]
[home:321] Test Title
[home:654] Sample Title
[home:789] Demo Title# using shortcut alias and short option
❯ nb b -q "example"
❯nb · homesearch: [example ]
[home:321] Test Title
[home:654] Sample Title
[home:789] Demo Title
```Search for [#tags](#-tagging) with the
[`-t`](#browse) / [`--tag`](#browse) / [`--tags`](#browse) options:```bash
# open to a list of items tagged with "#tag2" in the current notebook
❯ nb browse --tag tag2
❯nb · homesearch: [#tag2 ]
[home:654] Sample Title
[home:789] Demo Title# using shortcut alias and short option
❯ nb b -t tag2
❯nb · homesearch: [#tag2 ]
[home:654] Sample Title
[home:789] Demo Title
```For more information about search options, see [Search](#-search) and
[`nb search`](#search).#### `browse --gui`
To open any [`nb browse`](#browse) view in
the system's primary GUI web browser,
add the [`nb browse --gui`](#browse) / [`nb b -g`](#browse) option:```bash
# open the item with id 123 in the "sample" notebook in the system's primary GUI browser
nb browse sample:123 --gui# open the folder named "example" in the system's primary GUI browser,
# short option
nb browse example/ -g# open the current notebook in the system's primary GUI browser,
# shortcut alias and short option
nb b -g
```##### `browse --gui` Editing
By default,
[`nb browse --gui`](#browse)
uses the browser's default `` for editing items.[Ace](https://ace.c9.io/) is a text editor for GUI web browsers
that provides advanced text editing functionality,
including block selection and
[syntax highlighting](#gui-web-syntax-highlighting).To use Ace as the editor for [`nb browse --gui`](#browse),
add the following line to your `~/.nbrc` file:```bash
export NB_ACE_ENABLED=1
```The next time a form is loaded in [`nb browse`](#browse),
`nb` will automatically download
(from [GitHub](https://github.com/ajaxorg/ace-builds/)),
install,
and enable the Ace editor in
[`nb browse edit --gui`](#browse) and [`nb browse add --gui`](#browse).#### `browse` Portability
[`nb browse`](#browse) depends on
either [`socat`](https://www.kali.org/tools/socat/)
or
[`ncat`](https://nmap.org/ncat/) (available as part of
the `ncat` or `nmap` package in most package managers) and
[`pandoc`](https://pandoc.org/). When neither `socat` nor `ncat` is
available and the Bash version is 5.2 or higher, [`nb browse`](#browse)
falls back to a pure Bash implementation that supports all features
except the Ace editor. When only `pandoc` is available,
the current note is rendered and
[[wiki-style links]]
go to unrendered, original files.
When `socat`,`ncat`, or Bash 5.2+ is available without `pandoc`,
files in plain text formats are rendered with the original markup unconverted.
If neither `ncat`, `socat`, Bash 5.2+, nor `pandoc` is available,
[`nb browse`](#browse) falls back to the default behavior of [`nb show`](#show).When `nb` is installed on Windows,
`socat` ([MSYS](https://packages.msys2.org/package/socat),
[Cygwin](https://cygwin.com/packages/summary/socat.html)) is recommended.#### `browse` Privacy
[`nb browse`](#browse) is completely local and self-contained within `nb`,
from the CSS and JavaScript
all the way down through the HTTP request parsing and response building,
with no imports, libraries, frameworks, or third-party code
outside of the few binary dependencies
(`bash`, `git`, `ncat` / `socat`, `pandoc`),
the Linux / Unix environment,
and the optional [Ace editor](#ace-editor).Terminal web browsers don't use JavaScript, so visits from them are not
visible to some web analytics tools.
[`nb browse`](#browse) includes a number of additional features
to enhance privacy and avoid leaking information:- Page content is cached locally within each bookmark file,
making it readable in terminal and GUI web browsers
without requesting the page again or needing to be connected to the internet.
- `` tags in bookmarked content are removed to avoid requests.
- Outbound links are automatically rewritten to use an
[exit page redirect](https://geekthis.net/post/hide-http-referer-headers/#exit-page-redirect)
to mitigate leaking information via the
[referer header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer).
- All pages include the `` tag.
- Links include a `rel="noopener noreferrer"` attribute.
- `lynx` is opened with the `-noreferer` option.#### `browse` AsciiDoc
To [`browse`](#browse) items in [AsciiDoc](https://asciidoc.org/) format,
install [`asciidoctor`](https://asciidoctor.org/).#### Shortcut Alias: `nb b`
[`nb browse`](#browse) can also be used with the alias [`nb b`](#browse):
```bash
# open the current notebook in the terminal web browser
nb b# open the item with id 123 in the "example" notebook using the terminal web browser
nb b example:123# open the notebook named "sample" in the GUI web browser
nb b sample: -g
```For more information, see [`nb browse`](#browse).
### 🌄 Images
↑ ·
nb browse
,
nb import
,
nb open
,
nb show
`nb` can be used to view, organize, browse, reference, and work with images in
terminals,
web browsers,
and GUI applications.#### Image Items
[Import](#%EF%B8%8F-import--export) images with [`nb import`](#import):
```bash
# import the image file "example.png" into the current notebook
nb import example.png# import an image file from a URL into the current notebook
nb import https://raw.githubusercontent.com/xwmx/nb/master/docs/images/nb.png# nb import "sample.jpg" into the "demo" folder in the "example" notebook
nb import sample.jpg example:demo/
```Imported images are displayed with [`🌄` indicators](#indicators) in
[lists](#listing--filtering):```bash
❯ nb
home
----
[5] Example Five
[4] 🌄 example-image.png
[3] Example Three
[2] Example Two
[1] Example One
```Imported image items can be opened in the system GUI application for
the item's file type using [`nb open`](#open):```bash
# open the image "example-image.png" in the system GUI photo viewer
nb open example-image.png# open the image with id "4" in the system GUI photo viewer
nb 4 o
```Image items can be viewed in web browsers with [`nb browse`](#browse),
providing a convenient mechanism for
[browsing](#-browsing) notebooks and folders containing image collections.[`nb browse`](#browse) renders image items within in an `` tag
on the item page. Open the item page for an image item by passing a
[selector](#-selectors) to [`nb browse`](#browse), optionally including the
[`-g`](#browse) / [`--gui`](#browse) option
to open the page in the system GUI web browser:```bash
# open item with id "123" in the terminal web browser
nb browse 123# open item with id "456" in the "example" notebook in the GUI web browser
nb browse example:456 --gui# open item "example:456" in the GUI web browser, alternative
nb example:456 b -g
```The original file can be viewed or downloaded from the item page
by either clicking the image item or using the down arrow (`↓`) link.[`nb browse --gui`](#browse---gui) displays images in any GUI web browser.
Some terminal web browsers, such as [`w3m`](http://w3m.sourceforge.net/),
can be configured to display images.[`nb show`](#show) can display images directly in the terminal with
supported tools and configurations, including:- [`catimg`](https://github.com/posva/catimg)
- [Chafa](https://github.com/hpjansson/chafa)
- [ImageMagick](https://imagemagick.org/) with a terminal that
supports [sixels](https://en.wikipedia.org/wiki/Sixel)
- [`imgcat`](https://www.iterm2.com/documentation-images.html) with
[iTerm2](https://www.iterm2.com/)
- [kitty's `icat` kitten](https://sw.kovidgoyal.net/kitty/kittens/icat.html)
- [`termvisage`](https://github.com/AnonymouX47/termvisage)
- [`timg`](https://github.com/hzeller/timg)
- [`viu`](https://github.com/atanunq/viu)A preferred image viewer tool can be set with the
[`$NB_IMAGE_TOOL`](#nb_image_tool) variable in your `~/.nbrc` file,
which can be opened in your editor with [`nb settings edit`](#settings).#### Inline Images
Images can be referenced and rendered inline within
notes, bookmarks, and other items.To reference an image in the same notebook,
specify the image's relative path within the notebook:```markdown
# reference "example.jpg" from markdown
![](example.jpg)# reference "demo.png" in the "sample" folder from markdown
![](sample/demo.png)
```Images in any notebook can be referenced using the `--original` URL,
obtainable from the image's [`nb browse`](#browse) item page
by either clicking the image item or using the down arrow (`↓`) link.```markdown
# reference "example.jpg" in the "home" notebook with the --original URL
![](http://localhost:6789/--original/home/example.jpg)
```Image references in content are rendered inline within web browsers with
[`nb browse`](#browse) and [`nb show --render`](#show).`` tags are stripped from bookmarked content when rendering to HTML.
Inline images can still be used in other bookmark sections like
[`## Comment`](#-comment).### 🗂 Zettelkasten
Zettelkasten (German: "slip box") is a method of note-taking and
personal knowledge management modeled around a few key features:- Notes are taken liberally on index cards.
- Each note is numbered for easy reference.
- Index cards are organized into boxes.
- Index cards can reference other index cards.
- Cards can include tags and other metadata.Since `nb` works directly on plain text files
organized in normal system directories in normal git repositories,
`nb` is a very close digital analogue to physical zettelkasten note-taking.| Zettelkasten | `nb` |
|:-----------------:|:-----------------------------------------------:|
| index cards | [notes](#-notes) & [bookmarks](#-bookmarks) |
| numbering | ids & [selectors](#-selectors) |
| slip boxes | [notebooks](#-notebooks) |
| tags | [#tags](#-tagging) |
| metadata | [front matter](#front-matter) |
| cross-references | [[wiki-style links]] |
| fast note-taking | [`nb add`](#adding)/[`nb `](#-bookmarks) |For more information about Zettelkasten, see
[Wikipedia](https://en.wikipedia.org/wiki/Zettelkasten).### 📂 Folders
↑ ·
nb add
,
nb browse
,
nb folders
,
nb list
,
nb ls
Items can be organized in folders.
To add a note to a folder,
call [`nb add`](#add) with the folder's relative path within the notebook
followed by a slash:```bash
# add a new note in the folder named "example"
nb add example/# add a new note in the folder named "demo" in "example"
nb add example/demo/
````nb` automatically creates any intermediate folders as needed.
Folders can be created directly using [`nb add folder`](#add),
[`nb folders add`](#folders), and [`nb add --type folder`](#add):```bash
# create a new folder named "sample"
nb add folder sample# create a new folder named "sample", alternative
nb folders add sample# create a new folder named "demo"
nb add demo --type folder# create a folder named "example" containing a folder named "test"
nb add example/test --type folder
```To list the items in a folder, pass the folder relative path to
`nb`,
[`nb ls`](#ls),
[`nb list`](#list),
or [`nb browse`](#browse)
with a trailing slash:```bash
❯ nb example/demo/
home
----
[example/demo/3] Title Three
[example/demo/2] Title Two
[example/demo/1] Title One
```Folders can also be identified by the folder's id
and listed with a trailing slash:```bash
❯ nb list
[1] 📂 example❯ nb list 1/
[example/2] 📂 demo
[example/1] document.md❯ nb list 1/2/
[example/demo/3] Title Three
[example/demo/2] Title Two
[example/demo/1] Title One
```Items in folders can be idenitified with
the folder's relative path using either folder ids or names,
followed by the id, title, or filename of the item:```bash
# list item 1 ("Title One", one.md) in the example/demo/ folder
nb list example/demo/1# edit item 1 ("Title One", one.md) in the example/demo/ folder
nb edit example/2/one.md# show item 1 ("Title One", one.md) in the example/demo/ folder
nb show 1/2/Title\ One# delete item 1 ("Title One", one.md) in the example/demo/ folder
nb delete 1/demo/1
```For folders and items in other notebooks,
combine the relative path with the notebook name, separated by a colon:```bash
# list the contents of the "sample" folder in the "example" notebook
nb example:sample/# add an item to the "sample/demo" folder in the "example" notebook
nb add example:sample/demo/# edit item 3 in the "sample/demo" folder in the "example" notebook
nb edit example:sample/demo/3
```[Browse](#-browsing) starting at any folder with [`nb browse`](#browse):
```bash
❯ nb browse example:sample/demo/
❯nb · example : sample / demo /search: [ ]
[example:sample/demo/5] Title Five
[example:sample/demo/4] Title Four
[example:sample/demo/3] Title Three
[example:sample/demo/2] Title Two
[example:sample/demo/1] Title One
```For more information about identifying folders, see [Selectors](#-selectors).
### 📌 Pinning
↑ ·
nb pin
,
nb unpin
,
nb ls
,
nb browse
Items can be pinned so they appear first in
`nb`, [`nb ls`](#ls), and [`nb browse`](#browse):```bash
❯ nb
home
----
[2] 📌 Title Two
[5] Title Five
[4] Title Four
[3] Title Three
[1] Title One
```Use [`nb pin`](#pin) and [`nb unpin`](#unpin) to pin and unpin items:
```bash
❯ nb
home
----
[5] Title Five
[4] Title Four
[3] Title Three
[2] Title Two
[1] Title One❯ nb pin 4
Pinned: [4] four.md "Title Four"❯ nb pin 1
Pinned: [1] one.md "Title One"❯ nb
home
----
[4] 📌 Title Four
[1] 📌 Title One
[5] Title Five
[3] Title Three
[2] Title Two❯ nb unpin 4
Unpinned: [4] four.md "Title Four"❯ nb
home
----
[1] 📌 Title One
[5] Title Five
[4] Title Four
[3] Title Three
[2] Title Two
````nb` can also be configured to pin notes that contain
a specified [#hashtag](#-tagging) or other search pattern.
To enable tag / search-based pinning,
set the [`$NB_PINNED_PATTERN`](#nb_pinned_pattern) environment variable to
the desired [#tag](#-tagging) or pattern.For example, to treat all items tagged with `#pinned` as pinned items,
add the following line to your `~/.nbrc` file,
which can be opened in your editor with [`nb settings edit`](#settings):```bash
export NB_PINNED_PATTERN="#pinned"
```All [indicator icons](#indicators) in `nb` can be customized, so
to use a different character as the pindicator,
simply add a line like the following to your `~/.nbrc` file:```bash
export NB_INDICATOR_PINNED="💖"
``````bash
❯ nb
home
----
[1] 💖 Title One
[5] Title Five
[4] Title Four
[3] Title Three
[2] Title Two
```To bump an item to the top of the list without pinning, use the
[`bump` plugin](#bump).### 🔍 Search
Use [`nb search`](#search) (shortcut: [`nb q`](#search)) to
perform full text searches, with support for regular expressions,
[#tags](#-tagging), and `AND`, `OR`, and `NOT` queries:```bash
# search current notebook for "example query"
nb search "example query"# search the notebook "example" for "example query"
nb search example: "example query"# search the folder named "demo" for "example query"
nb search demo/ "example query"# search all unarchived notebooks for "example query" and list matching items
nb search "example query" --all --list# search for "example" AND "demo" with multiple arguments
nb search "example" "demo"# search for "example" AND "demo" with option
nb search "example" --and "demo"# search for "example" OR "sample" with argument
nb search "example|sample"# search for "example" OR "sample" with option
nb search "example" --or "sample"# search for items matching both "Example" AND "Sample", and NOT "Demo"
nb search "Example" --and "Sample" --not "Demo"# search items containing the hashtag "#example"
nb search "#example"# search with a regular expression
nb search "\d\d\d-\d\d\d\d"# search bookmarks for "example"
nb search "example" --type bookmark# search bookmarks for "example", alternative
nb bk q "example"# search the current notebook for "example query"
nb q "example query"# search the notebook named "example" for "example query"
nb q example: "example query"# search all unarchived notebooks for "example query" and list matching items
nb q -la "example query"
```[`nb search`](#search) prints the id number, filename,
and title of each matched file,
followed by each search query match and its line number,
with color highlighting:```bash
❯ nb search "example"
[314] 🔖 example.bookmark.md "Example Bookmark (example.com)"
--------------------------------------------------------------
1:# Example Bookmark (example.com)3:
[2718] example.md "Example Note"
--------------------------------
1:# Example Note
```To just print the note information line without the content matches,
use the [`-l`](#search) or [`--list`](#search) option:```bash
❯ nb search "example" --list
[314] 🔖 example.bookmark.md "Example Bookmark (example.com)"
[2718] example.md "Example Note"
```Multiple query arguments are treated as `AND` queries,
returning items that match all queries.
`AND` queries can also be specified with the
[`--and `](#search) option:```bash
# search for items tagged with "#example" AND "#demo" AND "#sample" using
# multiple arguments
nb q "#example" "#demo" "#sample"# options
nb q "#example" --and "#demo" --and "#sample"
````nb` matches `AND` query terms regardless of where they appear in a document,
an improvement over most approaches for performing `AND` queries
with command line tools,
which typically only match terms appearing on the same line.`OR` queries return items that match at least one of the queries
and can be created by separating terms in a single argument
with a pipe character `|` or with the [`--or `](#search) option:```bash
# search for "example" OR "sample" with argument
nb q "example|sample"# search for "example" OR "sample" with option
nb q "example" --or "sample"
```[`--or`](#search) and [`--and`](#search) queries can be used together:
```bash
nb q "example" --or "sample" --and "demo"
# equivalent: example|sample AND demo|sample
````NOT` queries exclude items that match the specified query and are
specified with [`--not `](#search), which can be used with
`--and` and `--or`:```bash
# search for items that match "Example", excluding items that also match "Sample"
nb search "Example" --not "Sample"# search for items matching both "Example" AND "Sample", and NOT "Demo"
nb search "Example" --and "Sample" --not "Demo"
```Search for [#tags](#-tagging) with flexible
[`nb search --tags []`](#search) / [`nb q -t []`](#search) options:```bash
# search for tags in the current notebook
nb search --tags# search for tags in the "sample" notebook, shortcut alias
nb sample:q --tags# search for items tagged with "#tag1"
nb search --tag tag1# search for items tagged with "#tag1", shortcut alias and short option
nb q -t tag1# search for items tagged with "#tag1", shortcut alias and argument
nb q \#tag1# search for items tagged with "#tag1", shortcut alias and argument, alternative
nb q "#tag1"# search for items in the "sample" notebook tagged with "#tag1" AND "#tag2"
nb sample:search --tag tag1 --tag tag2# search for items in the "sample" notebook tagged with "#tag1" AND "#tag2"
nb sample:q --tags tag1,tag2# search for items in the current notebook tagged with "#tag1" AND "#tag2"
nb q --tag tag1 --tag tag2# search for items in the current notebook tagged with "#tag1" OR "#tag2"
nb q -t tag1 --or -t tag2# search for items tagged with "#tag1" AND "#tag2" AND "#tag3"
nb q -t tag1 --tags tag2,tag3# search for items tagged with "#tag1" OR "#tag2" OR "#tag3"
nb q -t tag1 --or --tags tag2,tag3# search for items tagged with "#tag1" OR "#tag2" OR "#tag3"
nb q \#tag1 --or -t tag2 --or "#tag3"
```[`nb search`](#search) leverages Git's powerful built-in
[`git grep`](https://git-scm.com/docs/git-grep).
`nb` also supports performing searches with alternative search tools
using the [`--utility `](#search) option.Supported alternative search tools:
- [`rga`](https://github.com/phiresky/ripgrep-all)
- [`rg`](https://github.com/BurntSushi/ripgrep)
- [`ag`](https://github.com/ggreer/the_silver_searcher)
- [`ack`](https://beyondgrep.com/)
- [`grep`](https://en.wikipedia.org/wiki/Grep)##### Shortcut Alias: `nb q`
[`nb search`](#search) can also be used with the alias
[`nb q`](#search) (for "query"):```bash
# search for "example" and print matching excerpts
nb q "example"# search for "example" and list each matching file
nb q -l "example"# search for "example" in all unarchived notebooks
nb q -a "example"# search for "example" in the notbook named "sample"
nb sample:q "example"
```For more information about search, see [`nb help search`](#search).
##### Searching with `browse`
Searches can be performed within terminal and GUI web browsers using
[`nb browse --query`](#browse) / [`nb b -q`](#browse):```bash
❯ nb browse --query "#example"
❯nb · home : +search: [#example ]
[home:7] Title Seven
[home:32] Title Thirty-Two
[home:56] Title Fifty-Six
[home:135] Title One Hundred and Thirty-Five
```For more information, see [Browsing](#-browsing).
### ↔ Moving & Renaming
Use [`nb move`](#move) (alias: [`nb rename`](#move), shortcut: [`nb mv`](#move))
to move and rename items:```bash
# move "example.md" to "sample.org"
nb move example.md sample.org# rename note 2 ("example.md") to "New Name.md"
nb rename 2 "New Name"
```Items can be moved between notebooks and folders:
```bash
# move note 12 from the "example" notebook into "Sample Folder" in the "demo" notebook
nb move example:12 demo:Sample\ Folder/
```When the file extension is omitted, the existing extension is used:
```bash
# rename "example.bookmark.md" to "New Name.bookmark.md"
nb move example.bookmark.md "New Name"
```When only a file extension is specified, only the extension is updated:
```bash
# change the file extension of note 5 ("demo file.md") to .org ("demo file.org")
nb rename 5 .org
```Use [`nb rename --to-bookmark`](#move) to change the extension of a note
to `.bookmark.md`,
[`nb rename --to-todo`](#move) to change the extension to `.todo.md`,
and [`nb rename --to-note`](#move) to change the extension
of a bookmark or todo to either `.md` or the extension set with
[`nb set default_extension`](#default_extension):```bash
# rename note 3 ("example.md") to a bookmark named "example.bookmark.md"
nb rename 3 --to-bookmark# rename bookmark 6 ("sample.bookmark.md") to a note named "sample.md"
nb rename 6 --to-note# rename note 7 ("demo.md") to a todo named "demo.todo.md"
nb rename 7 --to-todo
```Use [`nb rename --to-title`](#move) to set the filename to the note title,
lowercased with spaces and disallowed filename characters replaced
with underscores:```bash
❯ nb rename 12 --to-title
Moving: [12] 20210101010000.md "Example Title"
To: example_title.md
Proceed? [y/N]
```Copy an item to a destination notebook, folder path, or filename
with [`nb copy`](#copy) (alias: [`nb duplicate`](#copy)):```bash
# copy item 456 to "sample.md"
nb copy 456 sample.md# copy item 678 to the "example" notebook
nb copy 678 example:# copy item 789 to the "demo" folder
nb copy 789 demo/# copy item 543 to test.md in the "sample" folder in the "example" notebook
nb copy 543 example:sample/test.md
```Omit a destination to copy the item in place:
```bash
# copy item 123 ("example.md") to example-1.md
❯ nb copy 123
Added: [124] example-1.md# copy item 123 ("example.md") to example-2.md, alias
❯ nb duplicate 123
Added: [125] example-2.md
```For more information about moving, renaming, and copying items, see
[`nb help move`](#move) and [`nb help copy`](#copy).### 🗒 Revision History
Whenever a note is added, modified, or deleted,
`nb` automatically commits the change to git transparently in the background.Use [`nb history`](#history) to view the revision history of
any notebook, folder, or item:```bash
# show history for current notebook
nb history# show history for note number 4
nb history 4# show history for note with filename example.md
nb history example.md# show history for note titled "Example"
nb history Example# show history for the notebook named "example"
nb example:history# show history for the notebook named "example", alternative
nb history example:# show the history for note 12 in the notebook named "example"
nb history example:12
```[`nb history`](#history) uses `git log` by default and prefers
[`tig`](https://github.com/jonas/tig) when available.#### Authorship
By default, git commits are attributed to the email and name configured in your
[global `git` configuration](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration).Change the email and name used for a notebook with
[`nb notebooks author`](#notebooks):```bash
# edit the commit author email and name for the current notebook
❯ nb notebooks author
Current configuration for: home
--------------------------
email (global): [email protected]
name (global): Example NameUpdate? [y/N]
# edit the commit author email and name for the notebook named "example"
❯ nb notebooks author example
Current configuration for: example
--------------------------
email (global): [email protected]
name (global): Example NameUpdate? [y/N]
```The updated author email and name applies to subsequent commits.
To use a different email and name from the beginning of a notebook's
history, create the new notebook using
[`nb notebooks add --author`](#notebooks) or
[`nb notebooks init --author`](#notebooks).### 📚 Notebooks
↑ ·
nb notebooks
,
nb archive
,
nb unarchive
,
nb use
You can create additional notebooks, each of which has its own version history.
Create a new notebook with [`nb notebooks add`](#notebooks):
```bash
# add a notebook named example
nb notebooks add example
````nb` and [`nb ls`](#ls) list the available notebooks above the list of notes:
```bash
❯ nb
example · home
--------------
[3] Title Three
[2] Title Two
[1] Title One
```Commands in `nb` run within the current notebook, and identifiers
such as ids, filenames, and titles refer to notes within the current notebook.
`nb edit 3`, for example, tells `nb` to
[`edit`](#edit) note with id `3` within the current notebook.To switch to a different notebook, use [`nb use`](#use):
```bash
# switch to the notebook named "example"
nb use example
```If you are in one notebook and you want
to perform a command in a different notebook without switching to it,
add the notebook name with a colon before the command name:```bash
# add a new note in the notebook "example"
nb example:add# add a new note in the notebook "example", shortcut alias
nb example:a# show note 5 in the notebook "example"
nb example:show 5# show note 5 in the notebook "example", shortcut alias
nb example:s 5# edit note 12 in the notebook "example"
nb example:edit 12# edit note 12 in the notebook "example", shortcut alias
nb example:e 12# search for "example query" in the notebook "example"
nb example:search "example query"# search for "example query" in the notebook "example", shortcut alias
nb example:q "example query"# show the revision history of the notebook "example"
nb example:history
```The notebook name with colon can also be used as a modifier to
the id, filename, or title:```bash
# edit note 12 in the notebook "example"
nb edit example:12# edit note 12 in the notebook "example", shortcut alias
nb e example:12# edit note 12 in the notebook "example", alternative
nb example:12 edit# edit note 12 in the notebook "example", alternative, shortcut alias
nb example:12 e# show note titled "misc" in the notebook "example"
nb show example:misc# show note titled "misc" in the notebook "example", shortcut alias
nb s example:misc# delete note with filename "todos.md" in the notebook "example", alternative
nb example:todos.md delete# delete note with filename "todos.md" in the notebook "example", alternative,
# shortcut alias
nb example:todos.md d
```When a notebook name with colon is called without a subcommand,
`nb` runs [`nb ls`](#ls) in the specified notebook:```bash
❯ nb example:
example · home
--------------
[example:3] Title Three
[example:2] Title Two
[example:1] Title One
```A bookmark can be created in another notebook by specifying
the notebook name with colon, then a space, then the URL and bookmark options:```bash
# create a new bookmark in a notebook named "sample"
❯ nb sample: https://example.com --tags tag1,tag2
```Notes can also be moved between notebooks:
```bash
# move note 3 from the current notebook to "example"
nb move 3 example:# move note 5 in the notebook "example" to the notebook "sample"
nb move example:5 sample:
```##### Example Workflow
The flexibility of `nb`'s argument handling makes it easy to
build commands step by step as items are listed, filtered, viewed, and edited,
particularly in combination with shell history:```bash
# list items in the "example" notebook
❯ nb example:
example · home
--------------
[example:3] Title Three
[example:2] Title Two
[example:1] Title One# filter list
❯ nb example: three
[example:3] Title Three# view item
❯ nb example:3 show
# opens item in `less`# edit item
❯ nb example:3 edit
# opens item in $EDITOR
```##### Notebooks and Tab Completion
[`nb` tab completion](#tab-completion) is optimized for
frequently running commands in various notebooks using the colon syntax,
so installing the completion scripts is recommended
and makes working with notebooks easy, fluid, and fun.For example, listing the contents of a notebook is usually as simple as typing
the first two or three characters of the name,
then pressing the `` key,
then pressing `` / ``:```bash
❯ nb exa
# completes to "example:"
❯ nb example:
example · home
--------------
[example:3] Title Three
[example:2] Title Two
[example:1] Title One
```Scoped notebook commands are also available in tab completion:
```bash
❯ nb exa
# completes to "example:"
❯ nb example:hi
# completes to "example:history"
```#### Notebooks, Tags, and Taxonomy
`nb` is optimized to work well with a collection of notebooks, so
notebooks are a good way to organize notes and bookmarks by top-level topic.[#tags](#-tagging) are searchable across notebooks and can be created ad hoc,
making notebooks and tags distinct and complementary organizational systems
in `nb`.Search for a tag in or across notebooks with
[`nb search`](#search) / [`nb q`](#search):```bash
# search for #tag in the current notebook
nb q --tag tag# search for #tag in all notebooks, short options
nb q -t tag -a# search for #tag in the "example" notebook, argument
nb q example: "#tag"
```#### Global and Local Notebooks
##### Global Notebooks
By default, all `nb` notebooks are global, making them
always accessible in the terminal regardless of the current working directory.
Global notebooks are stored in the directory configured in
[`nb set nb_dir`](#nb_dir),
which is `~/.nb` by default.##### Local Notebooks
`nb` also supports creating and working with local notebooks.
Local notebooks are notebooks that are
anywhere on the system outside of [`$NB_DIR`](#nb_dir-1).
Any folder can be an `nb` local notebook, which is just a normal folder
that has been initialized as a git repository and contains an `nb` .index file.
Initializing a folder as an `nb` local notebook is a very easy way to
add structured git versioning to any folder of documents and other files.When `nb` runs within a local notebook,
the local notebook is set as the current notebook:```bash
❯ nb
local · example · home
----------------------
[3] Title Three
[2] Title Two
[1] Title One
```A local notebook is always referred to by the name `local`
and otherwise behaves just like a global notebook
whenever a command is run from within it:```bash
# add a new note in the local notebook
nb add# edit note 15 in the local notebook
nb edit 15# move note titled "Todos" from the home notebook to the local notebook
nb move home:Todos local:# move note 1 from the local notebook to the home notebook
nb move 1 home:# search the local notebook for
nb search "query string"# search the local notebook and all unarchived global notebooks for
nb search "query string" --all
```Local notebooks can be created with [`nb notebooks init`](#notebooks):
```bash
# initialize the current directory as a notebook
nb notebooks init# create a new notebook at ~/example
nb notebooks init ~/example# clone an existing notebook to ~/example
nb notebooks init ~/example https://github.com/example/example.git
```Local notebooks can also be created by exporting a global notebook:
```bash
# export global notebook named "example" to "../path/to/destination"
nb notebooks export example ../path/to/destination# alternative
nb export example ../path/to/destination
```Local notebooks can also be imported, making them global:
```bash
# import notebook or folder at "../path/to/notebook"
nb notebooks import ../path/to/notebook# alternative
nb import ../path/to/notebook
```[`nb notebooks init`](#notebooks) and [`nb notebooks import`](#notebooks)
can be used together to easily turn any directory of existing files
into a global `nb` notebook:```bash
❯ ls
example-directory❯ nb notebooks init example-directory
Initialized local notebook: /home/username/example-directory❯ nb notebooks import example-directory
Imported notebook: example-directory❯ nb notebooks
example-directory
home
```#### Archiving Notebooks
↑ ·
nb archive
,
nb status
,
nb unarchive
Notebooks can be archived using
[`nb archive`](#archive) (shortcut: [`nb ar`](#archive)):```bash
# archive the current notebook
nb archive# archive the notebook named "example"
nb archive example# archive the current notebook, shortcut alias
nb ar# archive the notebook named "example", shortcut alias
nb ar example
```When a notebook is archived it is not included in
[`nb`](#ls) / [`nb ls`](#ls) output,
[`nb search --all`](#search),
or tab completion,
nor synced automatically with [`nb sync --all`](#sync).```bash
❯ nb
example1 · example2 · example3 · [1 archived]
---------------------------------------------
[3] Title Three
[2] Title Two
[1] Title One
```Archived notebooks can still be used individually
using normal notebook commands:```bash
# switch the current notebook to the archived notebook "example"
nb use example# run the `list` subcommand in the archived notebook "example"
nb example:list
```Check a notebook's archival status with
[`nb status`](#status) (shortcut: [`nb st`](#status)) and
[`nb notebooks status`](#notebooks):```bash
# print status information, including archival status, for the current notebook
nb status# print status information, including archival status, for the notebook named "example"
nb status example# print status information, including archival status, for the current notebook,
# shortcut alias
nb st# print status information, including archival status, for the notebook named "example",
# shortcut alias
nb st example# print the archival status of the current notebook
nb notebooks status# print the archival status of the notebook named "example"
nb notebooks status example
```Use [`nb unarchive`](#unarchive) (shortcut: [`nb unar`](#unarchive))
to unarchive a notebook:```bash
# unarchive the current notebook
nb unarchive# unarchive the notebook named "example"
nb unarchive example
```For more information about working with notebooks, see
[`nb help notebooks`](#notebooks),
[`nb help archive`](#archive),
and [`nb help unarchive`](#unarchive).For technical details about notebooks, see
[`nb` Notebook Specification](#nb-notebook-specification).### 🔄 Git Sync
Each notebook can be synced with a remote git repository by
setting the remote URL using [`nb remote`](#remote):```bash
# set the current notebook's remote to a private GitHub repository
nb remote set https://github.com/example/example# set the remote for the notebook named "example"
nb example:remote set https://github.com/example/example
```Any notebook with a remote URL will sync automatically
every time a command is run in that notebook.When you use `nb` on multiple systems, you can
set a notebook on each system to the same remote
and `nb` will keep everything in sync in the background
every time there's a change in that notebook.Since each notebook has its own git history,
you can have some notebooks syncing with remotes
while other notebooks are only available locally on that system.Many services provide free private git repositories, so
git syncing with `nb` is easy, free, and vendor-independent.
You can also sync your notes using
Dropbox, Drive, Box, Syncthing, or another syncing tool
by changing your `nb` directory with
[`nb set nb_dir `](#nb_dir),
and git syncing will still work simultaneously.Clone an existing notebook by passing the URL to
[`nb notebooks add`](#notebooks):```bash
# create a new notebook named "example" cloned from a private GitLab repository
nb notebooks add example https://gitlab.com/example/example.git
```Turn off syncing for a notebook by removing the remote:
```bash
# remove the remote from the current notebook
nb remote remove# remove the remote from the notebook named "example"
nb example:remote remove
```Automatic git syncing can be turned on or off with
[`nb set auto_sync`](#auto_sync).To sync manually, use [`nb sync`](#sync):
```bash
# manually sync the current notebook
nb sync# manually sync the notebook named "example"
nb example:sync
```To bypass `nb` syncing and run `git` commands directly within a
notebook, use [`nb git`](#git):```bash
# run `git fetch` in the current notebook
nb git fetch origin# run `git status` in the notebook named "example"
nb example:git status
```#### Syncing Multiple Notebooks with One Remote
Multiple notebooks can be synced to one remote using orphan branches.
An
[orphan branch](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---orphanltnewbranchgt)
is a branch with a history that is independent
from the repository's `main`, `master`,
or equivalent primary branch history.
To sync a notebook with a new orphan branch,
add the remote using [`nb remote set`](#remote)
and select the option to create a new orphan branch.
The name of orphan branch is derived from notebook name
and can alternatively be specified as an argument to
[`nb remote set`](#remote):```bash
# set the remote for the current notebook to a remote URL and branch
nb remote set https://github.com/xwmx/example demo-branch
```To create a notebook using an existing orphan branch on a remote,
pass the branch name to
[`nb init`](#init),
[`nb notebooks add`](#notebooks), or
[`nb notebooks init`](#notebooks) after the URL:```bash
# initialize new "home" notebook with the branch "sample-branch" on the remote
nb init https://github.com/xwmx/example sample-branch# add a new "example" notebook from the branch "example-branch" on the remote
nb notebooks add example https://github.com/xwmx/example example-branch
```To list all branches on a remote, use [`nb remote branches`](#remote):
```bash
# list all branches on the current remote
nb remote branches# list all branches on a remote repository identified by a URL
nb remote branches "https://github.com/xwmx/example"
```For information about assigning remotes, see [`nb help remote`](#remote).
#### Private Repositories and Git Credentials
Syncing with private repositories requires
configuring git to not prompt for credentials.
For repositories cloned over HTTPS,
[credentials can be cached with git
](https://docs.github.com/en/free-pro-team@latest/github/using-git/caching-your-github-credentials-in-git).
For repositories cloned over SSH,
[keys can be added to the ssh-agent
](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).Use [`nb sync`](#sync) within a notebook to determine
whether your configuration is working.
If `nb sync` displays a password prompt,
then follow the instructions above to configure your credentials.
The password prompt can be used to authenticate, but
`nb` does not cache or otherwise handle git credentials in any way,
so there will likely be multiple password prompts during each sync
if credentials are not configured.#### Sync Conflict Resolution
`nb` handles git operations automatically, so
you shouldn't ever need to use the `git` command line tool directly.
`nb` merges changes when syncing
and handles conflicts using a couple different strategies.When [`nb sync`](#sync) encounters a conflict in a text file
and can't cleanly merge overlapping local and remote changes,
`nb` saves both versions within the file separated by git conflict markers
and prints a message indicating which files contain conflicting text.
Use [`nb edit`](#edit) to remove the conflict markers
and delete any unwanted text.For example, in the following file, the second list item was changed
on two systems, and git has no way to determine which one we want to keep:```
# Example Title- List Item apple
<<<<<<< HEAD
- List Item apricot
=======
- List Item pluot
>>>>>>> 719od01... [nb] Commit
- List Item plum
```The local change is between the lines starting with
`<<<<<<<` and `=======`,
while the remote change is between the
`=======` and `>>>>>>>`
lines.To resolve this conflict by keeping both items, simply
edit the file with [`nb edit`](#edit) and
remove the lines starting with `<<<<<<<`, `=======`, and `>>>>>>>`:```
# Example Title- List Item apple
- List Item apricot
- List Item pluot
- List Item plum
```When `nb` encounters a conflict in a binary file,
such as an encrypted note,
both versions of the file are saved in the notebook as individual files,
with `--conflicted-copy` appended to the filename
of the version from the remote.
To resolve a conflicted copy of a binary file,
compare both versions and merge them manually,
then delete the `--conflicted-copy`.If you do encounter a conflict that `nb` says it can't merge at all,
[`nb git`](#git) and [`nb run`](#run) can be used to
perform git and shell operations within the notebook
to resolve the conflict manually.
Please also
[open an issue](https://github.com/xwmx/nb/issues/new)
with any relevant details
that could inform a strategy for handling any such cases automatically.### ↕️ Import / Export
↑ ·
nb import
,
nb export
,
nb browse
Files of any type can be imported into a notebook using
[`nb import`](#import) (shortcut: [`nb i`](#import)).
[`nb edit`](#edit) and [`nb open`](#open) open files in
your system's default application for that file type.```bash
# import an image file
nb import ~/Pictures/example.png# open image in your default image viewer
nb open example.png# import a .docx file
nb import ~/Documents/example.docx# open .docx file in Word or your system's .docx viewer
nb open example.docx
```Multiple filenames and globbing are supported:
```bash
# import all files and directories in the current directory
nb import ./*# import all markdown files in the current directory
nb import ./*.md# import example.md and sample.md in the current directory
nb import example.md sample.md
```[`nb import`](#import) can also download and import files directly from the web:
```bash
# import a PDF file from the web
nb import https://example.com/example.pdf
# Imported "https://example.com/example.pdf" to "example.pdf"# open example.pdf in your system's PDF viewer
nb open example.pdf
```Some imported file types have [indicators](#indicators) to make them
easier to identify in lists:```bash
❯ nb
home
----
[6] 📖 example-ebook.epub
[5] 🌄 example-picture.png
[4] 📄 example-document.docx
[3] 📹 example-video.mp4
[2] 🔉 example-audio.mp3
[1] 📂 Example Folder
```Notes, bookmarks, and other files can be exported using [`nb export`](#export).
If [Pandoc](https://pandoc.org/) is installed,
notes can be automatically converted to any of the
[formats supported by Pandoc](https://pandoc.org/MANUAL.html#option--to).
By default, the output format is determined by the file extension:```bash
# export a Markdown note to a .docx Microsoft Office Word document
nb export example.md /path/to/example.docx# export a note titled "Movies" to an HTML web page.
nb export Movies /path/to/example.html
```For more control over the `pandoc` options, use the
[`nb export pandoc`](#export) subcommand:```bash
# export note 42 as an epub with pandoc options
nb export pandoc 42 --from markdown_strict --to epub -o path/to/example.epub
```[`nb export notebook`](#export) and [`nb import notebook`](#import) can be
used to export and import notebooks:```bash
# export global notebook named "example" to "../path/to/destination"
nb export notebook example ../path/to/destination# import notebook or folder at "../path/to/notebook"
nb import notebook ../path/to/notebook
```[`nb export notebook`](#export) and [`nb import notebook`](#import)
behave like aliases for
[`nb notebooks export`](#notebooks) and [`nb notebooks import`](#notebooks),
and the subcommands can be used interchangeably.For more information about imported and exported notebooks, see
[Global and Local Notebooks](#global-and-local-notebooks).For [`nb import`](#import) and [`nb export`](#export) help information, see
[`nb help import`](#import) and [`nb help export`](#export).#### Exporting with `browse`
Items can be exported using terminal and GUI [web browsers](#-browsing).
Use the down arrow (`↓`) link
on the [`nb browse`](#browse) item page
to download the original file:```bash
❯ nb browse 123
❯nb · home : 123 · ↓ | +example.pdf
```### ⚙️ `set` & `settings`
↑ ·
Variables,
nb settings
,
nb unset
[`nb set`](#settings) and [`nb settings`](#settings)
open the settings prompt,
which provides an easy way to change your `nb` settings.```bash
nb set
```To update a setting in the prompt,
enter the setting name or number and then enter the new value.
`nb` will add the setting to your `~/.nbrc` configuration file.#### Example: editor
`nb` can be configured to use a specific command line editor
using the `editor` setting.The settings prompt for a setting can be started by passing
the setting name or number to [`nb set`](#settings):```bash
❯ nb set editor
[6] editor
------
The command line text editor used by `nb`.• Example Values:
atom
code
emacs
hx
macdown
mate
micro
nano
pico
subl
vi
vimEDITOR is currently set to vim
Enter a new value, unset to set to the default value, or q to quit.
Value:
```A setting can also be updated without the prompt by
passing both the name and value to [`nb set`](#settings):```bash
# set editor with setting name
❯ nb set editor code
EDITOR set to code# set editor with setting number (6)
❯ nb set 6 code
EDITOR set to code# set the color theme to blacklight
❯ nb set color_theme blacklight
NB_COLOR_THEME set to blacklight# set the default `ls` limit to 10
❯ nb set limit 10
NB_LIMIT set to 10
```Use [`nb settings get`](#settings) to print the value of a setting:
```bash
❯ nb settings get editor
code❯ nb settings get 6
code
```Use
[`nb unset`](#unset) or
[`nb settings unset`](#settings)
to unset a setting and revert to the default:```bash
❯ nb unset editor
EDITOR restored to the default: vim❯ nb settings get editor
vim
```[`nb set`](#settings) and [`nb settings`](#settings)
are aliases that refer to the same subcommand,
so the two subcommand names can be used interchangeably.For more information about [`set`](#settings) and [`settings`](#settings), see
[`nb help settings`](#settings).### 🎨 Color Themes
↑ ·
nb set color_theme
,
nb set syntax_theme
,
nb set color_primary
,
nb set color_secondary
`nb` uses color to highlight various interface elements, including
ids and [selectors](#-selectors),
the current notebook name,
the shell prompt,
divider lines,
[syntax elements](#terminal-syntax-highlighting-theme),
and links.`nb` includes several built-in color themes
and also supports user-defined themes.
The current color theme can be set using [`nb set color_theme`](#color_theme):```bash
nb set color_theme
```#### Built-in Color Themes
##### `blacklight`
| ![blacklight](https://xwmx.github.io/misc/nb/images/nb-theme-blacklight-home.png) | ![blacklight](https://xwmx.github.io/misc/nb/images/nb-theme-blacklight-web.png) |
|:--:|:--:|
| | |##### `console`
| ![console](https://xwmx.github.io/misc/nb/images/nb-theme-console-home.png) | ![console](https://xwmx.github.io/misc/nb/images/nb-theme-console-web.png) |
|:--:|:--:|
| | |##### `desert`
| ![desert](https://xwmx.github.io/misc/nb/images/nb-theme-desert-home.png) | ![desert](https://xwmx.github.io/misc/nb/images/nb-theme-desert-web.png) |
|:--:|:--:|
| | |##### `electro`
| ![electro](https://xwmx.github.io/misc/nb/images/nb-theme-electro-home.png) | ![electro](https://xwmx.github.io/misc/nb/images/nb-theme-electro-web.png) |
|:--:|:--:|
| | |##### `forest`
| ![forest](https://xwmx.github.io/misc/nb/images/nb-theme-forest-home.png) | ![forest](https://xwmx.github.io/misc/nb/images/nb-theme-forest-web.png) |
|:--:|:--:|
| | |##### `nb` (default)
| ![nb](https://xwmx.github.io/misc/nb/images/nb-theme-nb-home.png) | ![nb](https://xwmx.github.io/misc/nb/images/nb-theme-nb-web.png) |
|:--:|:--:|
| | |##### `ocean`
| ![ocean](https://xwmx.github.io/misc/nb/images/nb-theme-ocean-home.png) | ![ocean](https://xwmx.github.io/misc/nb/images/nb-theme-ocean-web.png) |
|:--:|:--:|
| | |##### `raspberry`
| ![raspberry](https://xwmx.github.io/misc/nb/images/nb-theme-raspberry-home.png) | ![raspberry](https://xwmx.github.io/misc/nb/images/nb-theme-raspberry-web.png) |
|:--:|:--:|
| | |##### `smoke`
| ![smoke](https://xwmx.github.io/misc/nb/images/nb-theme-monochrome-home.png) | ![smoke](https://xwmx.github.io/misc/nb/images/nb-theme-smoke-web.png) |
|:--:|:--:|
| | |##### `unicorn`
| ![unicorn](https://xwmx.github.io/misc/nb/images/nb-theme-unicorn-home.png) | ![unicorn](https://xwmx.github.io/misc/nb/images/nb-theme-unicorn-web.png) |
|:--:|:--:|
| | |##### `utility`
| ![utility](https://xwmx.github.io/misc/nb/images/nb-theme-utility-home.png) | ![utility](https://xwmx.github.io/misc/nb/images/nb-theme-utility-web.png) |
|:--:|:--:|
| | |#### Custom Color Themes
Color themes are
[`nb` plugins](#-plugins) with a `.nb-theme` file extension.
`.nb-theme` files are expected to contain one `if` statement
testing for the theme name
and setting the color environment variables to `tput` ANSI color numbers:```bash
# turquoise.nb-theme
if [[ "${NB_COLOR_THEME}" == "turquoise" ]]
then
export NB_COLOR_PRIMARY=43
export NB_COLOR_SECONDARY=38
fi
```View this theme as a complete file:
[`plugins/turquoise.nb-theme`](https://github.com/xwmx/nb/blob/master/plugins/turquoise.nb-theme)Themes can be installed using [`nb plugins`](#plugins):
```bash
❯ nb plugins install https://github.com/xwmx/nb/blob/master/plugins/turquoise.nb-theme
Plugin installed:
/home/example/.nb/.plugins/turquoise.nb-theme
```Once a theme is installed,
use [`nb set color_theme`](#color_theme) to set it as the current theme:```bash
❯ nb set color_theme turquoise
NB_COLOR_THEME set to turquoise
```The primary and secondary colors can also be overridden individually,
making color themes easily customizable:```bash
# open the settings prompt for the primary color
nb set color_primary# open the settings prompt for the secondary color
nb set color_secondary
```To view a table of available colors and numbers, run:
```bash
nb set colors
```#### Terminal Syntax Highlighting Theme
`nb` displays files with syntax highlighting when
[`bat`](https://github.com/sharkdp/bat),
[`highlight`](http://www.andre-simon.de/doku/highlight/en/highlight.php),
or
[Pygments](https://pygments.org/)
is installed.When `bat` is installed, syntax highlighting
color themes are available for both light and dark terminal backgrounds.
To view a list of available themes
and set the syntax highlighting color theme,
use [`nb set syntax_theme`](#syntax_theme).#### GUI Web Syntax Highlighting
Syntax highlighting is also available when
viewing and editing items in text formats with
[`nb browse --gui`](#browse---gui),
which incorporates the color theme's primary color into the syntax theme:
#### Indicators
`nb` uses emoji characters to represent information about files in lists.
These characters are referred to internally as "indicators"
and can be customized by assigning a different character to
the indicator's environment variable in your `~/.nbrc` file,
which can be opened with [`nb settings edit`](#settings).For example, to use a different indicator for pinned items,
add a line like the following to your `~/.nbrc` file:```bash
export NB_INDICATOR_PINNED="✨"
```To turn off an indicator, assign the variable to an empty string:
```bash
export NB_INDICATOR_PINNED=""
```Available indicator [variables](#-variables) with default values:
```bash
export NB_INDICATOR_AUDIO="🔉"
export NB_INDICATOR_BOOKMARK="🔖"
export NB_INDICATOR_DOCUMENT="📄"
export NB_INDICATOR_EBOOK="📖"
export NB_INDICATOR_ENCRYPTED="🔒"
export NB_INDICATOR_FOLDER="📂"
export NB_INDICATOR_IMAGE="🌄"
export NB_INDICATOR_PINNED="📌"
export NB_INDICATOR_TODO="✔️ "
export NB_INDICATOR_TODO_DONE="✅"
export NB_INDICATOR_VIDEO="📹"
```### $ Shell Theme Support
- [`astral` Zsh Theme](https://github.com/xwmx/astral) - Displays the
current notebook name in the context line of the prompt.### 🔌 Plugins
`nb` includes support for plugins, which can be used to create new
subcommands, design themes, and otherwise extend the functionality of `nb`.`nb` supports two types of plugins, identified by their file extensions:
.nb-theme
- Plugins defining color themes.
.nb-plugin
- Plugins defining new subcommands and adding functionality.
Plugins are managed with the [`nb plugins`](#plugins) subcommand and
are installed in the `${NB_DIR}/.plugins` directory.
Plugins can be installed from either a URL or a path using the
[`nb plugins install`](#plugins) subcommand.
```bash
# install a plugin from a URL
nb plugins install https://raw.githubusercontent.com/xwmx/nb/master/plugins/clip.nb-plugin
# install a plugin from a standard GitHub URL
nb plugins install https://github.com/xwmx/nb/blob/master/plugins/example.nb-plugin
# install a theme from a standard GitHub URL
nb plugins install https://github.com/xwmx/nb/blob/master/plugins/turquoise.nb-theme
# install a plugin from a path
nb plugins install plugins/example.nb-plugin
```
The `` should be the full URL to the plugin file.
`nb` also recognizes regular GitHub URLs,
which can be used interchangeably with raw GitHub URLs.
Installed plugins can be listed with [`nb plugins`](#plugins),
which optionally takes a name and prints full paths:
```bash
❯ nb plugins
clip.nb-plugin
example.nb-plugin
turquoise.nb-theme
❯ nb plugins clip.nb-plugin
clip.nb-plugin
❯ nb plugins --paths
/home/example/.nb/.plugins/clip.nb-plugin
/home/example/.nb/.plugins/example.nb-plugin
/home/example/.nb/.plugins/turquoise.nb-theme
❯ nb plugins turquoise.nb-theme --paths
/home/example/.nb/.plugins/turquoise.nb-theme
```
Use [`nb plugins uninstall`](#plugins) to uninstall a plugin:
```bash
❯ nb plugins uninstall example.nb-plugin
Plugin successfully uninstalled:
/home/example/.nb/.plugins/example.nb-plugin
```
#### Creating Plugins
Plugins are written in a Bash-compatible shell scripting language
and have an `.nb-plugin` extension.
`nb` includes a few example plugins:
- [`example.nb-plugin`](https://github.com/xwmx/nb/blob/master/plugins/example.nb-plugin)
- [`clip.nb-plugin`](https://github.com/xwmx/nb/blob/master/plugins/clip.nb-plugin)
- [`ebook.nb-plugin`](https://github.com/xwmx/nb/blob/master/plugins/ebook.nb-plugin)
Create a new subcommand in three easy steps:
##### 1. Add the new subcommand name with `_subcommands add `:
```bash
_subcommands add "example"
```
##### 2. Define help and usage text with `_subcommands describe `:
```bash
_subcommands describe "example" <`](#plugins),
and you can publish it on GitHub, GitLab,
or anywhere else online and install it with
[`nb plugins install `](#plugins).
#### API
The `nb` API is the [command line interface](#nb-help), which is designed for
composability and provides a variety of powerful options for interacting with
notes, bookmarks, notebooks, and `nb` functionality. Within plugins,
subcommands can be called using their function names, which are named with
leading underscores. Options can be used to output information in formats
suitable for parsing and processing:
```bash
# print the content of note 3 to standard output with no color
_show 3 --print --no-color
# list all unarchived global notebook names
_notebooks --names --no-color --unarchived --global
# list all filenames in the current notebook
_list --filenames --no-id --no-indicator
# print the path to the current notebook
_notebooks current --path
```
`nb` automatically scans arguments for
[selectors](#-selectors) with notebook names
and updates the current notebook if a valid one is found.
Identifier selectors are passed to subcommands as arguments along with
any subcommand options. Use [`show `](#show) to query
information about the file specified in the selector. For example, to
obtain the filename of a selector-specified file, use
[`show --filename`](#show):
```bash
_example() {
local _selector="${1:-}"
[[ -z "${_selector:-}" ]] && printf "Usage: example \\n" && exit 1
# Get the filename using the selector.
local _filename=
_filename="$(_show "${_selector}" --filename)"
# Rest of subcommand function...
}
```
[`notebooks current --path`](#notebooks) returns the path to the current
notebook:
```bash
# _example() continued:
# get the notebook path
local _notebook_path=
_notebook_path="$(_notebooks current --path)"
# print the file at "${_notebook_path}/${_filename}" to standard output
cat "${_notebook_path}/${_filename}"
```
See
[`clip.nb-plugin`](https://github.com/xwmx/nb/blob/master/plugins/clip.nb-plugin)
for a practical example using both [`show `](#show) and
[`notebooks current --path`](#notebooks) along with other
subcommands called using their underscore-prefixed function names.
### `:/` Selectors
Items in `nb` are primarily identified using structured arguments called
"selectors." Selectors are like addresses for notebooks, folders, and items.
A selector can be as simple as an id like `123` or folder path like `example/`,
or it can combine multiple elements to identify
an item in a nested folder within a particular notebook, such as:
```bash
cli:tools/shellcheck/home-page.bookmark.md
```
An item, folder, or notebook selector is constructed by specifying the
notebook name, folder path, and / or item identifier
in the following pattern:
```text
notebook:folder/path/item-idenitifer
```
Represented in a [docopt](http://docopt.org/)-like format:
```text
[:][/][ | | ]
```
Notebooks are identified by the notebook name followed by a colon.
Folder and item identifiers without a notebook name refer to
items within the current notebook.
When a selector consists of notebook name and colon
with no folder path or item identifier,
the command runs in the root folder of the notebook:
```bash
# list items in the "example" notebook
nb example:
# add a new note named "Example Title" to the "example" notebook
nb add example: --title "Example Title"
# edit item with id "123" in the notebook "example"
nb edit example:123
```
A notebook selector can be combined with a subcommand name to
run the command within the notebook:
```bash
# list all items in the "example" notebook and display excerpts
nb example:list -e
# edit item with id "123" in the "example" notebook
nb example:edit 123
# show the git history for the notebook named "example"
nb example:history
```
Folders are identified by relative path from the notebook root.
Folders can be referenced by either id or name, and segments
in nested paths can mix and match names and ids:
```bash
# list items in the folder named "sample" in the folder named demo"
nb sample/demo/
# add a new item to the folder named "demo" in the folder with id "3"
nb add 3/demo/
# show the history of the folder with id "4" in the folder named
# "sample" in the notebook named "example"
nb history example:sample/4/
```
A trailing slash indicates that the command is expected to operate on
the contents of the folder. When a trailing slash is omitted, the
selector refers to the folder itself:
```bash
❯ nb list sample
[1] 📂 sample
❯ nb list sample/
[sample/3] Title Three
[sample/2] Title Two
[sample/1] Title One
```
For more information about folders, see [Folders](#-folders).
An item is identified by id, filename, or title, optionally preceded by
notebook name or folder path:
```bash
# edit item with id "123"
nb edit 123
# open the item titled "demo title" in the folder with id "3"
nb open 3/demo\ title
# show "file.md" in the "sample" folder in the "example" notebook
nb show example:sample/file.md
```
Items can also be specified using the full path:
```bash
# edit "demo.md" in the "sample" folder in the "home" notebook
nb edit /home/example/.nb/home/sample/demo.md
```
##### Examples
*Idenitifer Selectors*
```text
123
example.md
title
relative/path/to/123
relative/path/to/demo.md
relative/path/to/title
/full/path/to/sample.md
notebook:123
notebook:example.md
notebook:title
notebook:relative/path/to/123
notebook:relative/path/to/demo.md
notebook:relative/path/to/title
```
*Subcommand Selectors*
```text
notebook:
notebook:show
notebook:history
notebook:a
notebook:q
```
### `01` Metadata
Metadata in `nb` is primarily derived from git, the filesystem, and file
content. For example, displayed timestamps are derived from
[`git log`](https://git-scm.com/docs/git-log), with [`nb show --added`](#show)
displaying the datetime of the first commit containing the file and
[`nb show --updated`](#show) displaying the datetime of the last commit in
which the file was modified. Meanwhile, the file system's modified
timestamp is used for sorting.
`nb` also uses plain text files to store ids and state information in
git, including
[`.index` files](https://github.com/xwmx/nb#index-files),
[`.pindex` files](https://github.com/xwmx/nb#pindex-files),
and [`.archived` files](https://github.com/xwmx/nb#archived-notebooks).
#### Front Matter
User-defined metadata can be added to notes in `nb` using [front
matter](https://jekyllrb.com/docs/front-matter/). Front matter is a
simple, human accessible, and future-friendly method for defining metadata
fields in plain text and is well supported in tools for working with
Markdown.
Front matter is defined within a Markdown file with triple-dashed lines
(`---`) indicating the start and end of the block, with each field represented
by a key name with a colon followed by the value:
```markdown
---
title: Example Title
author: xwmx
year: 2021
---
Example content.
More example content:
- one
- two
- three
```
Any metadata can be placed in the front matter block. `nb` uses the
`title:` field for listing, filtering, and selecting items, if one is
present, and ignores any other fields.
The simple `key: value` syntax is suitable for many metadata fields.
More complex data can be defined using additional
[YAML](https://en.wikipedia.org/wiki/YAML)
capabilities.
### `❯` Interactive Shell
`nb` has an interactive shell that can be started with
[`nb shell`](#shell), [`nb -i`](#nb-help), or [`nb --interactive`](#nb-help):
```bash
$ nb shell
__ _
\ \ _ __ | |__
\ \ | '_ \| '_ \
/ / | | | | |_) |
/_/ |_| |_|_.__/
------------------
nb shell started. Enter ls to list notes and notebooks.
Enter help for usage information. Enter exit to exit.
nb❯ ls
home
----
[3] Example
[2] Sample
[1] Demo
nb❯ edit 3 --content "New content."
Updated: [3] Example
nb❯ bookmark https://example.com
Added: [4] 🔖 example.bookmark.md "Example Title (example.com)"
nb❯ ls
home
----
[4] 🔖 Example Title (example.com)
[3] Example
[2] Sample
[1] Demo
nb❯ bookmark url 4
https://example.com
nb❯ search "example"
[4] example.bookmark.md "Example (example.com)"
-----------------------------------------------
1:# Example (example.com)
3:
[3] example.md "Example"
------------------------
1:# Example
nb❯ exit
$
```
The `nb` shell recognizes all `nb` subcommands and options,
providing a streamlined, distraction-free approach for working with `nb`.
### Shortcut Aliases
Several core `nb` subcommands have shortcut aliases to make
them faster to work with:
```bash
# `a` (add): add a new note named "example.md"
nb a example.md
# `+` (add): add a new note titled "Example Title"
nb + --title "Example Title"
# `b` (browse): open the folder named "sample" in the web browser
nb b sample/
# `o` (open): open the URL from bookmark 12 in your web browser
nb o 12
# `p` (peek): open the URL from bookmark 6 in your terminal browser
nb p 6
# `e` (edit): edit note 5
nb e 5
# `d` (delete): delete note 19
nb d 19
# `d` (delete): delete note 123 in the notebook named "example:"
nb - example:123
# `s` (show): show note 27
nb s 27
# `q` (search): search notes for "example query"
nb q "example query"
# `h` (help): display the help information for the `add` subcommand
nb h add
# `u` (use): switch to example-notebook
nb u example-notebook
```
For more commands and options, run
[`nb help`](#nb-help) or
[`nb help `](#subcommands)
### `?` Help
add ·
archive ·
bookmark ·
browse ·
completions ·
copy ·
count ·
delete ·
do ·
edit ·
env ·
export ·
folders ·
git ·
help ·
history ·
import ·
init ·
list ·
ls ·
move ·
notebooks ·
open ·
peek ·
pin ·
plugins ·
remote ·
run ·
search ·
settings ·
shell ·
show ·
status ·
subcommands ·
sync ·
tasks ·
todo ·
unarchive ·
undo ·
unpin ·
unset ·
update ·
use ·
version
#### `nb help`
[↑](#-help) · See also:
[`help`](#help)
```text
__ _
\ \ _ __ | |__
\ \ | '_ \| '_ \
/ / | | | | |_) |
/_/ |_| |_|_.__/
[nb] Command line and local web note-taking, bookmarking, and archiving with
plain text data storage, encryption, filtering and search, pinning, #tagging,
Git-backed versioning and syncing, Pandoc-backed conversion, global and local
notebooks, customizable color themes, [[wiki-style linking]], plugins, and more
in a single portable, user-friendly script.
Help:
nb help Display this help information.
nb help View help information for .
nb help --colors View information about color settings.
nb help --readme View the `nb` README file.
Usage:
nb
nb [...] [ | | | | ]
nb [] [...]
nb add [:][/][] []
[-b | --browse] [-c | --content ] [--edit]
[-e | --encrypt] [-f | --filename ]
[--folder ] [--tags ,...]
[-t | --title ] [--type ]
nb add bookmark [...]
nb add folder []
nb add todo [...]
nb archive []
nb bookmark [...]
nb bookmark [:][/]
[-c | --comment ] [--edit] [-e | --encrypt]
[-f | --filename ] [--no-request]
[-q | --quote ] [--save-source]
[-r ( | ) | --related ( | )]...
[-t ,... | --tags ,...] [--title ]
nb bookmark [list [...]]
nb bookmark (open | peek | url) ( | | | )
nb bookmark (edit | delete) ( | | | )
nb bookmark search
nb browse [:][/][ | | ] [--daemon]
[-g | --gui] [-n | --notebooks] [-p | --print] [-q | --query ]
[-s | --serve] [-t | --tag | --tags ,...]
nb browse add [:][/][]
[-c | --content ] [--tags ,...]
[-t | --title ]
nb browse delete ([:][/][ | | ])
nb browse edit ([:][/][ | | ])
nb completions (check | install [-d | --download] | uninstall)
nb copy ([:][/][ | | ])
[[:][/]]
nb count [:][/]
nb delete ([:][/][ | | ])...
[-f | --force]
nb do ([:][/][ | | ])
[]
nb edit ([:][/][ | | ])
[-c | --content ] [--edit]
[-e | --editor ] [--overwrite] [--prepend]
nb export ([:][/][ | | ])
[-f | --force] [...]
nb export notebook []
nb export pandoc ([:][/][ | | ])
[...]
nb folders (add | delete) [:][/]
nb folders ...
nb git [checkpoint [] | dirty]
nb git ...
nb help [] [-p | --print]
nb help [-c | --colors] | [-r | --readme] | [-s | --short] [-p | --print]
nb history [:][/][ | | ]
nb import [copy | download | move] (... | ) [--convert]
[:][