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处于打开状态。
obsidianWhen to Use
适用场景
- Use when managing vault content through the Obsidian CLI.
- Use when developing or debugging Obsidian plugins and themes from the command line.
- Use when the user wants shell-driven interaction with a running Obsidian app.
- 当通过Obsidian CLI管理库内容时使用。
- 当从命令行开发或调试Obsidian插件与主题时使用。
- 当用户希望通过Shell与运行中的Obsidian应用进行交互时使用。
Command 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
插件开发
Develop/test cycle
开发/测试流程
After making code changes to a plugin or theme, follow this workflow:
- Reload the plugin to pick up changes:
bash
obsidian plugin:reload id=my-plugin - Check for errors — if errors appear, fix and repeat from step 1:
bash
obsidian dev:errors - Verify visually with a screenshot or DOM inspection:
bash
obsidian dev:screenshot path=screenshot.png obsidian dev:dom selector=".workspace-leaf" text - Check console output for warnings or unexpected logs:
bash
obsidian dev:console level=error
对插件或主题进行代码更改后,遵循以下工作流程:
- 重新加载插件以应用更改:
bash
obsidian plugin:reload id=my-plugin - 检查错误 — 如果出现错误,修复后从步骤1重复:
bash
obsidian dev:errors - 通过截图或DOM检查进行视觉验证:
bash
obsidian dev:screenshot path=screenshot.png obsidian dev:dom selector=".workspace-leaf" text - 检查控制台输出中的警告或意外日志:
bash
obsidian dev:console level=error
Additional developer commands
其他开发者命令
Run JavaScript in the app context:
bash
obsidian eval code="app.vault.getFiles().length"Inspect CSS values:
bash
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在应用上下文中运行JavaScript:
bash
obsidian eval code="app.vault.getFiles().length"检查CSS值:
bash
obsidian dev:css selector=".workspace-leaf" prop=background-color切换移动设备模拟:
bash
obsidian dev:mobile on运行查看更多开发者命令,包括CDP和调试器控制。
obsidian helpLimitations
局限性
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
- 仅当任务明确符合上述描述的范围时使用此技能。
- 不要将输出视为特定环境下验证、测试或专家评审的替代品。
- 如果缺少必要的输入、权限、安全边界或成功标准,请停止操作并请求澄清。