Why “cmdbook”?
Because it’s your Command Book – a small notebook where you store the shell commands you actually care about, with tags and descriptions, and recall them in seconds.
CmdBook is a small CLI for storing and retrieving shell commands.
It keeps a local SQLite database with an FTS5 index for fast search. It does not execute commands; it helps you remember, organize, and copy/paste them quickly.
record.mp4
- Store commands with description, tags, shell, and working directory
- Fast full-text search (command + description) via SQLite FTS5
- Filter by tag
- Mark commands as favorites and list favorites first
- Duplicate detection on
add(with--forceto override) - Show a single entry, optionally copy to clipboard
- Edit metadata, delete entries
- Export/Import as JSON for backup or migration
- Simple
statscommand (total commands, top tags, last added) - Local-only data (
~/.cmdbook/cmdbook.db)
- Node.js 18, 20, or 22 (recommended)
better-sqlite3provides prebuilt binaries for LTS releases; other versions may try to compile from source. - macOS or Linux (tested). Windows may work via WSL.
npm install -g cmdbookThen:
cmdbook --helpIf cmdbook is not found, ensure your global npm bin directory is on PATH or open a new terminal.
git clone https://github.com/doniaskima/CmdBook.git
cd CmdBook
npm install
npm run build
npm link # makes `cmdbook` available globally# Save commands
cmdbook add "docker system prune -af" -d "Clean Docker garbage" -t docker,cleanup
cmdbook add "git rebase -i HEAD~5" -d "Interactive rebase last 5" -t git
# Mark a favorite
cmdbook fav 1
# List most recent (favorites first)
cmdbook list -n 10
cmdbook list --favorites
# Search (full text over command + description, highlighted)
cmdbook search docker
cmdbook search "interactive rebase" -t git
# Show one and copy to clipboard
cmdbook show 1 --copy
# Edit metadata
cmdbook edit 1 -d "Prune images/containers/networks/volumes" -t docker,cleanup
# Delete, export, import
cmdbook rm 2
cmdbook export > backup.json
cmdbook import backup.json
# Stats
cmdbook statsAdd a new command.
Options:
-d, --desc <text>: description-t, --tags <docker,git>: comma-separated tags-s, --shell <name>:bash|zsh|pwsh|fish(default:bash)-c, --cwd <path>: working directory hint-f, --force: insert even if the exact same command already exists
Example:
cmdbook add "ssh -i ~/.ssh/key user@host" \
-d "Prod jumpbox" \
-t ssh,prod \
-s bash \
-c ~/workIf a command with the same text already exists and you don’t pass --force, CmdBook will show the existing entry instead of inserting a duplicate.
List recent commands.
Options:
-n, --limit <n>: number of rows (default: 20)-t, --tag <tag>: filter by single tag-F, --favorites: only show favorites
Favorites are always shown first.
Example:
cmdbook list -n 50
cmdbook list -t docker
cmdbook list --favoritesFull-text search across command and description (with highlighted matches).
Options:
-t, --tag <tag>: filter by tag
Example:
cmdbook search "rebase"
cmdbook search "docker prune" -t dockerDisplay a single command.
Options:
--copy: copy the command text to clipboard
Example:
cmdbook show 3 --copyUpdate description, tags, shell, or cwd.
Options:
-d, --desc <text>-t, --tags <tags>-s, --shell <name>-c, --cwd <path>
Example:
cmdbook edit 3 -t docker,cleanup,space -d "Aggressive prune"Delete a command.
cmdbook rm 7Mark a command as favorite (shows with a ★ and sorted first).
cmdbook fav 1Remove the favorite mark.
cmdbook unfav 1Show a small summary (count, top tags, last added):
cmdbook statsPrint all entries as JSON to stdout.
cmdbook export > backup.jsonImport entries from a JSON array (compatible with export).
cmdbook import backup.json- Database file:
~/.cmdbook/cmdbook.db
On macOS, open it via:
open ~/.cmdbook- Full-text search uses SQLite FTS5 over
cmdanddesc. - Tag filtering is a simple
LIKEfilter on the normalized comma-separated string. - Search terms are highlighted in both command and description.
-
better-sqlite3build errors on uncommon Node versions:- Prefer Node 18/20/22 via
nvm. - If compiling, ensure build tools are installed (Xcode Command Line Tools on macOS).
- Prefer Node 18/20/22 via
-
Global command not found after install/link:
-
Confirm the global npm bin directory is on your
PATH:npm bin -g which cmdbook
-
Open a new shell to refresh
PATH.
-
- All data is stored locally. No network or telemetry is used.
- Exported backups are plain JSON; treat them like any other sensitive notes.
- Build:
npm run build - Local run:
npm run dev - Watch dev:
npm run dev:watch
MIT license – see LICENSE for details.