Nb技能使用说明
2026-03-29
新闻来源:网淘吧
围观:11
电脑广告
手机广告
nb - 命令行笔记工具
⚠️重要提示:切勿手动编辑 nb Git 仓库中的文件(
~/.nb/*)!务必使用nb命令行工具,以确保正确的索引和 Git 提交。
一款命令行和本地网页笔记、书签和归档工具,采用纯文本数据存储、Git 支持的版本控制以及维基风格的链接。

快速参考
笔记本
# List all notebooks
nb notebooks
# Switch to a notebook
nb use <notebook>
# Create a new notebook
nb notebooks add <name>
# Show current notebook
nb notebooks current
添加笔记
# Add a note with title
nb add -t "Title" -c "Content here"
# Add note to specific notebook
nb <notebook>: add -t "Title" -c "Content"
# Add note with tags
nb add -t "Title" --tags tag1,tag2
# Add note from file content
nb add <notebook>:filename.md
列出笔记
# List notes in current notebook
nb list
# List all notes (no limit)
nb list -a
# List notes in specific notebook
nb <notebook>: list
# List with excerpts
nb list -e
# List with tags shown
nb list --tags
显示笔记
# Show note by ID or title
nb show <id>
nb show "<title>"
# Show note from specific notebook
nb show <notebook>:<id>
# Print content (for piping)
nb show <id> --print
搜索笔记
# Search across all notebooks
nb search "query"
# Search in specific notebook
nb <notebook>: search "query"
# Search with AND/OR/NOT
nb search "term1" --and "term2"
nb search "term1" --or "term2"
nb search "term1" --not "exclude"
# Search by tag
nb search --tag "tagname"
编辑笔记
# Edit by ID
nb edit <id>
# Edit by title
nb edit "<title>"
# Append content
nb edit <id> -c "New content to append"
# Prepend content
nb edit <id> -c "Content at top" --prepend
# Overwrite content
nb edit <id> -c "Replace all" --overwrite
删除笔记
# Delete by ID (will prompt)
nb delete <id>
# Force delete without prompt
nb delete <id> -f
移动/重命名
# Move note to another notebook
nb move <id> <notebook>:
# Rename a note
nb move <id> new-filename.md
待办事项
# Add a todo
nb todo add "Task title"
# Add todo with due date
nb todo add "Task" --due "2026-01-15"
# List open todos
nb todos open
# List closed todos
nb todos closed
# Mark todo as done
nb todo do <id>
# Mark todo as not done
nb todo undo <id>
书签
# Add a bookmark
nb bookmark <url>
# Add with comment
nb bookmark <url> -c "My comment"
# Add with tags
nb bookmark <url> --tags reference,dev
# List bookmarks
nb bookmark list
# Search bookmarks
nb bookmark search "query"
Git 操作
# Sync with remote
nb sync
# Create checkpoint (commit)
nb git checkpoint "Message"
# Check dirty status
nb git dirty
# Run any git command
nb git status
nb git log --oneline -5
文件夹
# Add folder to notebook
nb folders add <folder-name>
# List folders
nb folders
# Add note to folder
nb add <folder>/<filename>.md
常用模式
添加包含完整内容的笔记
对于较长的笔记,可创建临时文件并导入:
# Write content to temp file first, then copy to nb
cp /tmp/note.md ~/.nb/<notebook>/
cd ~/.nb/<notebook> && git add . && git commit -m "Add note"
nb <notebook>: index rebuild
跨笔记本全局搜索
# Search everything
nb search "term" --all
# Search by type
nb search "term" --type bookmark
nb search "term" --type todo
数据存储位置
笔记存储于~/.nb/<笔记本名称>/目录下,采用支持Git版本控制的Markdown文件格式
~/.nb/
├── notebook-name-1/ # Your first notebook
├── notebook-name-2/ # Your second notebook
└── ...
使用技巧
- 使用
nb <笔记本名称>:前缀可针对特定笔记本进行操作 - ID即
nb list - 命令中显示的数字编号
- 可使用标题替代ID(含空格时需加引号)
- 所有变更均会自动通过Git提交
使用nb sync
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~