obsidian-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian CLI
Obsidian CLI
Use the CLI to interact with a running Obsidian instance. Requires Obsidian to be open.
obsidian使用 CLI与运行中的Obsidian实例进行交互。需要Obsidian处于打开状态。
obsidianCommand reference
命令参考
Run to see all available commands. This is always up to date. Full docs: https://help.obsidian.md/cli
obsidian help运行查看所有可用命令。该命令列表始终保持最新。完整文档:https://help.obsidian.md/cli
obsidian helpSyntax
语法
Parameters take a value with . Quote values with spaces:
=bash
obsidian create name="My Note" content="Hello world"Flags are boolean switches with no value:
bash
obsidian create name="My Note" silent overwriteFor multiline content use for newline and for tab.
\n\t参数使用赋值。包含空格的值需要加引号:
=bash
obsidian create name="My Note" content="Hello world"标志是无值的布尔开关:
bash
obsidian create name="My Note" silent overwrite对于多行内容,使用表示换行,表示制表符。
\n\tFile targeting
文件定位
Many commands accept or to target a file. Without either, the active file is used.
filepath- — resolves like a wikilink (name only, no path or extension needed)
file=<name> - — exact path from vault root, e.g.
path=<path>folder/note.md
许多命令接受或参数来指定目标文件。如果未指定,则使用当前活跃文件。
filepath- — 类似维基链接解析(仅需名称,无需路径或扩展名)
file=<名称> - — 从库根目录开始的精确路径,例如
path=<路径>folder/note.md
Vault targeting
库定位
Commands target the most recently focused vault by default. Use as the first parameter to target a specific vault:
vault=<name>bash
obsidian vault="My Vault" search query="test"默认情况下,命令会针对最近聚焦的库。使用作为第一个参数来指定特定库:
vault=<名称>bash
obsidian vault="My Vault" search query="test"Common patterns
常用示例
bash
obsidian read file="My Note"
obsidian create name="New Note" content="# Hello" template="Template" silent
obsidian append file="My Note" content="New line"
obsidian search query="search term" limit=10
obsidian daily:read
obsidian daily:append content="- [ ] New task"
obsidian property:set name="status" value="done" file="My Note"
obsidian tasks daily todo
obsidian tags sort=count counts
obsidian backlinks file="My Note"Use on any command to copy output to clipboard. Use to prevent files from opening. Use on list commands to get a count.
--copysilenttotalbash
obsidian read file="My Note"
obsidian create name="New Note" content="# Hello" template="Template" silent
obsidian append file="My Note" content="New line"
obsidian search query="search term" limit=10
obsidian daily:read
obsidian daily:append content="- [ ] New task"
obsidian property:set name="status" value="done" file="My Note"
obsidian tasks daily todo
obsidian tags sort=count counts
obsidian backlinks file="My Note"在任何命令后添加可将输出复制到剪贴板。使用标志可防止文件打开。在列表类命令中使用可获取计数。
--copysilenttotalPlugin development
插件开发
Reload a plugin after code changes — essential for the develop/test cycle:
bash
obsidian plugin:reload id=my-pluginRun JavaScript in the app context:
bash
obsidian eval code="app.vault.getFiles().length"Check for errors and console output:
bash
obsidian dev:errors
obsidian dev:console
obsidian dev:console level=errorTake a screenshot for visual testing:
bash
obsidian dev:screenshot path=screenshot.pngInspect DOM and CSS:
bash
obsidian dev:dom selector=".workspace-leaf" text
obsidian dev:css selector=".workspace-leaf" prop=background-colorToggle mobile emulation:
bash
obsidian dev:mobile onRun to see additional developer commands including CDP and debugger controls.
obsidian help代码变更后重新加载插件 — 这是开发/测试流程中的关键步骤:
bash
obsidian plugin:reload id=my-plugin在应用上下文中运行JavaScript:
bash
obsidian eval code="app.vault.getFiles().length"检查错误和控制台输出:
bash
obsidian dev:errors
obsidian dev:console
obsidian dev:console level=error截图用于视觉测试:
bash
obsidian dev:screenshot path=screenshot.png检查DOM和CSS:
bash
obsidian dev:dom selector=".workspace-leaf" text
obsidian dev:css selector=".workspace-leaf" prop=background-color切换移动端模拟:
bash
obsidian dev:mobile on运行查看更多开发者命令,包括CDP和调试器控制。
obsidian help