obsidian-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian CLI
Obsidian CLI
Run to control Obsidian from the terminal. The app must be running for most commands; the first command will launch Obsidian if not open.
obsidian <command>Run or for the canonical, always-up-to-date command reference. This skill documents common patterns and non-obvious behaviors.
obsidian helpobsidian help <command>运行 从终端控制Obsidian。大多数命令要求应用处于运行状态;如果Obsidian未打开,第一条命令会启动它。
obsidian <command>运行 或 获取官方的、实时更新的命令参考。本技能文档记录了常见用法和非显而易见的特性。
obsidian helpobsidian help <command>Targeting vaults and files
定位库与文件
- Vault: as first parameter. Default: cwd if it's a vault folder, else the active vault.
vault=<name> - File: resolves like a wikilink (name only, no path or extension needed).
file=<name>for exact path from vault root.path=<path> - TUI: Run with no args for interactive mode; omit the
obsidianprefix inside.obsidian
- 库(Vault):将 作为第一个参数。默认值:如果当前工作目录是库文件夹则使用它,否则使用活动库。
vault=<name> - 文件:像维基链接一样解析(仅需名称,无需路径或扩展名)。使用
file=<name>指定从库根目录开始的精确路径。path=<path> - TUI:不带参数运行 进入交互模式;在交互模式内可省略
obsidian前缀。obsidian
Parameters and flags
参数与标志
- Parameters: . Quote values with spaces:
param=value.content="Hello world" - Flags: Boolean, no value: ,
silent,overwrite.newtab - Multiline content: Use for newlines,
\nfor tabs in\t.content=
- 参数:格式为 。包含空格的值需加引号:
param=value。content="Hello world" - 标志:布尔型,无值,例如 、
silent、overwrite。newtab - 多行内容:在 中使用
content=表示换行,\n表示制表符。\t
Search, links, and structure
搜索、链接与结构
bash
obsidian search query="text" [path=folder] [limit=n] [format=text|json] [total] [case]
obsidian search:context query="text" [path=folder] [limit=n] # includes surrounding context
obsidian links [file=Note] [total]
obsidian backlinks [file=Note] [counts] [total]
obsidian outline [file=Note] [format=tree|md]
obsidian orphans [total] [active] # notes with no links to or from them
obsidian deadends [total] [active] # notes with no outgoing links
obsidian unresolved [total] [counts] [verbose] # broken wikilinks
obsidian tags [active] [file=Note] [total] [counts] [sort=count]
obsidian tag name=project [total] [verbose]bash
obsidian search query="text" [path=folder] [limit=n] [format=text|json] [total] [case]
obsidian search:context query="text" [path=folder] [limit=n] # 包含上下文内容
obsidian links [file=Note] [total]
obsidian backlinks [file=Note] [counts] [total]
obsidian outline [file=Note] [format=tree|md]
obsidian orphans [total] [active] # 无入站和出站链接的笔记
obsidian deadends [total] [active] # 无出站链接的笔记
obsidian unresolved [total] [counts] [verbose] # 失效的维基链接
obsidian tags [active] [file=Note] [total] [counts] [sort=count]
obsidian tag name=project [total] [verbose]Common patterns
常见用法
Notes and content
笔记与内容
To peek at a note without reading its full content, use or .
property:readproperties file=Notebash
obsidian read file="Note" # Use this to read the content of a wikilink
obsidian create name="Note" content="# Title\n\nBody" [template=Name] [overwrite] [silent]
obsidian append file="Note" content="- [ ] Task"
obsidian prepend file="Note" content="# Header\n"
obsidian move file="Note" to=folder/newpath.md
obsidian rename file="Note" name="New file name"
obsidian delete file="Note"若无需查看完整内容即可快速查看笔记信息,可使用 或 。
property:readproperties file=Notebash
obsidian read file="Note" # 用于读取维基链接指向的笔记内容
obsidian create name="Note" content="# Title\n\nBody" [template=Name] [overwrite] [silent]
obsidian append file="Note" content="- [ ] Task"
obsidian prepend file="Note" content="# Header\n"
obsidian move file="Note" to=folder/newpath.md
obsidian rename file="Note" name="New file name"
obsidian delete file="Note"Daily notes (Daily notes plugin)
每日笔记(Daily notes 插件)
bash
obsidian daily:read
obsidian daily [paneType=tab|split|window] [open]
obsidian daily:append content="- [ ] Buy groceries" [inline] [open]
obsidian daily:prepend content="- [ ] Morning routine" [inline] # goes after frontmatter
obsidian daily:path # returns expected path even if file doesn't exist yetbash
obsidian daily:read
obsidian daily [paneType=tab|split|window] [open]
obsidian daily:append content="- [ ] Buy groceries" [inline] [open]
obsidian daily:prepend content="- [ ] Morning routine" [inline] # 插入在前置元数据之后
obsidian daily:path # 即使文件尚未存在,也会返回预期路径Tasks
任务
bash
obsidian tasks [daily] [file=Note] [todo] [done] [status="x"] [total] [verbose]
obsidian task ref=path:line [toggle] [done] [todo] [daily]bash
obsidian tasks [daily] [file=Note] [todo] [done] [status="x"] [total] [verbose]
obsidian task ref=path:line [toggle] [done] [todo] [daily]Properties and frontmatter
属性与前置元数据
bash
obsidian properties [active] [file=Note] [total] [counts] [format=yaml|json|tsv]
obsidian property:read name=status [file=Note]
obsidian property:set name=status value=done [file=Note]
obsidian property:remove name=status [file=Note]bash
obsidian properties [active] [file=Note] [total] [counts] [format=yaml|json|tsv]
obsidian property:read name=status [file=Note]
obsidian property:set name=status value=done [file=Note]
obsidian property:remove name=status [file=Note]Bases (Bases plugin)
Bases(Bases 插件)
bash
obsidian bases
obsidian base:views [file=base.base]
obsidian base:query [file=base.base] [view=name] [format=json|csv|tsv|md|paths]
obsidian base:create name="Item" content="..." [open] [newtab]bash
obsidian bases
obsidian base:views [file=base.base]
obsidian base:query [file=base.base] [view=name] [format=json|csv|tsv|md|paths]
obsidian base:create name="Item" content="..." [open] [newtab]Developer commands
开发者命令
Reload a plugin after code changes — essential for the develop/test cycle:
bash
obsidian plugin:reload id=my-plugin
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path=screenshot.png
obsidian dev:dom selector=".cm-editor" [text] [attr=class]
obsidian dev:css selector=".cm-editor" [prop=color]
obsidian dev:console [clear] [limit=10] [level=log|warn|error]
obsidian dev:errors [clear]代码变更后重新加载插件——这是开发/测试循环的关键步骤:
bash
obsidian plugin:reload id=my-plugin
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path=screenshot.png
obsidian dev:dom selector=".cm-editor" [text] [attr=class]
obsidian dev:css selector=".cm-editor" [prop=color]
obsidian dev:console [clear] [limit=10] [level=log|warn|error]
obsidian dev:errors [clear]Quick reference
快速参考
| Task | Command |
|---|---|
| List commands | |
| Open daily note | |
| Append to daily | |
| Search vault | |
| Read active/specified file | |
| Create from template | |
| List tags with counts | |
| List tasks from daily | |
| Find broken wikilinks | |
| Find orphan notes | |
| 任务 | 命令 |
|---|---|
| 列出所有命令 | |
| 打开每日笔记 | |
| 追加内容到每日笔记 | |
| 搜索整个库 | |
| 读取活动/指定文件 | |
| 从模板创建笔记 | |
| 带计数列出所有标签 | |
| 列出每日笔记中的任务 | |
| 查找失效的维基链接 | |
| 查找孤立笔记 | |
References
参考资料
- — full command list (always up to date)
obsidian help - — help for a specific command
obsidian help <command> - Obsidian CLI docs (Obsidian)
- —— 完整命令列表(实时更新)
obsidian help - —— 特定命令的帮助文档
obsidian help <command> - Obsidian CLI 官方文档