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- — 像 wikilink 一样解析(只需名称,无需路径或扩展名)
file=<name> - — 从仓库根目录开始的精确路径,例如
path=<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=<name>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 help