obsidian-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian CLI

Obsidian CLI

Use the
obsidian
CLI to interact with a running Obsidian instance. Requires Obsidian to be open.
使用
obsidian
CLI与运行中的Obsidian实例交互。要求Obsidian处于打开状态。

When 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
obsidian help
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

Syntax

语法

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 overwrite
For multiline content use
\n
for newline and
\t
for tab.
参数通过
=
指定值。对包含空格的值使用引号:
bash
obsidian create name="My Note" content="Hello world"
标志是无值的布尔开关:
bash
obsidian create name="My Note" silent overwrite
多行内容使用
\n
表示换行,
\t
表示制表符。

File targeting

文件定位

Many commands accept
file
or
path
to target a file. Without either, the active file is used.
  • file=<name>
    — resolves like a wikilink (name only, no path or extension needed)
  • path=<path>
    — exact path from vault root, e.g.
    folder/note.md
许多命令接受
file
path
来指定目标文件。如果两者都不指定,则使用当前活动文件。
  • file=<名称>
    — 类似维基链接解析(仅需名称,无需路径或扩展名)
  • path=<路径>
    — 从库根目录开始的精确路径,例如
    folder/note.md

Vault targeting

库定位

Commands target the most recently focused vault by default. Use
vault=<name>
as the first parameter to target a specific vault:
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
--copy
on any command to copy output to clipboard. Use
silent
to prevent files from opening. Use
total
on list commands to get a count.
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"
在任何命令后使用
--copy
可将输出复制到剪贴板。使用
silent
可防止文件打开。在列表类命令中使用
total
可获取计数。

Plugin development

插件开发

Develop/test cycle

开发/测试流程

After making code changes to a plugin or theme, follow this workflow:
  1. Reload the plugin to pick up changes:
    bash
    obsidian plugin:reload id=my-plugin
  2. Check for errors — if errors appear, fix and repeat from step 1:
    bash
    obsidian dev:errors
  3. Verify visually with a screenshot or DOM inspection:
    bash
    obsidian dev:screenshot path=screenshot.png
    obsidian dev:dom selector=".workspace-leaf" text
  4. Check console output for warnings or unexpected logs:
    bash
    obsidian dev:console level=error
对插件或主题进行代码更改后,遵循以下工作流程:
  1. 重新加载插件以应用更改:
    bash
    obsidian plugin:reload id=my-plugin
  2. 检查错误 — 如果出现错误,修复后从步骤1重复:
    bash
    obsidian dev:errors
  3. 通过截图或DOM检查进行视觉验证
    bash
    obsidian dev:screenshot path=screenshot.png
    obsidian dev:dom selector=".workspace-leaf" text
  4. 检查控制台输出中的警告或意外日志
    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-color
Toggle mobile emulation:
bash
obsidian dev:mobile on
Run
obsidian help
to see additional developer commands including CDP and debugger controls.
在应用上下文中运行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
运行
obsidian help
查看更多开发者命令,包括CDP和调试器控制。

Limitations

局限性

  • 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.
  • 仅当任务明确符合上述描述的范围时使用此技能。
  • 不要将输出视为特定环境下验证、测试或专家评审的替代品。
  • 如果缺少必要的输入、权限、安全边界或成功标准,请停止操作并请求澄清。