obsidian-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian CLI

Obsidian CLI

The official Obsidian CLI (released in v1.12, February 2026) lets you control every aspect of Obsidian from the terminal. It communicates with a running Obsidian desktop instance via IPC.
Read
references/command-reference.md
when you need specific flags, output formats, or subcommands for any command group. It covers all 130+ commands with full parameter tables and has a table of contents at the top.
官方Obsidian CLI(2026年2月随v1.12版本发布)支持你通过终端控制Obsidian的所有功能,它通过IPC与运行中的Obsidian桌面端实例通信。
如果你需要查询任意命令组的特定参数、输出格式或子命令,请查阅
references/command-reference.md
。该文档覆盖了全部130+命令的完整参数表,顶部附有目录。

Prerequisites

前置条件

RequirementDetails
Obsidian Desktopv1.12.0+
CLI enabledSettings → Command line interface → Toggle ON
Obsidian runningThe desktop app must be running for CLI to work (IPC)
要求详情
Obsidian桌面端v1.12.0及以上版本
启用CLI功能设置 → 命令行界面 → 开启开关
Obsidian处于运行状态桌面应用必须处于运行状态CLI才能正常工作(依赖IPC通信)

Platform Notes

平台注意事项

  • macOS / Linux: The
    obsidian
    binary is registered in PATH automatically when you enable CLI in settings.
  • Windows: Requires an
    Obsidian.com
    redirector file placed alongside
    Obsidian.exe
    . Must run with normal user privileges — admin terminals produce silent failures.
    • If colon subcommands (
      property:set
      ,
      daily:append
      , etc.) with parameters return exit 127, check that
      Obsidian.com
      exists alongside
      Obsidian.exe
      . If missing, you have an outdated installer — download the latest from obsidian.md/download and reinstall.
    • Git Bash / MSYS2 users: Bash resolves
      obsidian
      to
      Obsidian.exe
      (GUI) instead of
      Obsidian.com
      (CLI), causing colon+params to fail with exit 127 even when
      Obsidian.com
      is present. Create a wrapper script — see Troubleshooting.
  • Headless Linux: Use the
    .deb
    package (not snap). Run under
    xvfb
    . Prefix commands with
    DISPLAY=:5
    (or your xvfb display number). Ensure
    PrivateTmp=false
    if running as a service.
  • macOS / Linux: 你在设置中启用CLI功能后,
    obsidian
    二进制文件会自动注册到PATH中。
  • Windows: 需要在
    Obsidian.exe
    同级目录下放置
    Obsidian.com
    重定向文件。必须使用普通用户权限运行——管理员终端会出现无提示的失败问题。
    • 如果带参数的冒号子命令(
      property:set
      daily:append
      等)返回退出码127,请检查
      Obsidian.exe
      同级目录下是否存在
      Obsidian.com
      。如果缺失说明你的安装包版本过旧,请从obsidian.md/download下载最新版本重新安装。
    • Git Bash / MSYS2用户: Bash会将
      obsidian
      解析为
      Obsidian.exe
      (GUI程序)而非
      Obsidian.com
      (CLI程序),即便
      Obsidian.com
      存在,冒号+参数的命令也会失败并返回退出码127。请创建一个包装脚本,详见故障排除部分。
  • 无界面Linux: 使用
    .deb
    安装包(不要用snap包),在
    xvfb
    环境下运行,命令前添加前缀
    DISPLAY=:5
    (替换为你的xvfb显示编号)。如果以服务运行,请确保
    PrivateTmp=false

Syntax

语法

All parameters use
key=value
syntax. Quote values containing spaces.
bash
obsidian <command> [subcommand] [key=value ...] [flags]
所有参数使用**
key=value
**语法,包含空格的参数值需要加引号。
bash
obsidian <command> [subcommand] [key=value ...] [flags]

Multi-Vault

多vault支持

Target a specific vault by making it the first argument:
bash
obsidian "My Vault" daily:read
obsidian "Work Notes" search query="meeting"
If omitted, the CLI targets the most recently active vault.
将目标vault名称作为第一个参数即可指定操作的vault:
bash
obsidian "My Vault" daily:read
obsidian "Work Notes" search query="meeting"
如果省略vault名称,CLI会默认操作最近激活的vault。

Command Overview

命令概览

The CLI provides 130+ commands across these groups:
GroupKey CommandsPurpose
files
read
,
create
,
append
,
prepend
,
move
,
rename
,
delete
,
files
,
folders
,
file
,
random
Note CRUD and file discovery
daily
daily
,
daily:read
,
daily:append
,
daily:prepend
,
daily:path
Daily note operations
search
search
,
search:context
Full-text search;
search:context
returns matching lines
properties
properties
,
property:read
,
property:set
,
property:remove
,
aliases
Frontmatter/metadata management
tags
tags
,
tag
Tag listing, counts, and filtering
tasks
tasks
,
task
Task querying, filtering, and toggling
links
backlinks
,
links
,
unresolved
,
orphans
,
deadends
Graph and link analysis
bookmarks
bookmarks
,
bookmark
List and add bookmarks
templates
templates
,
template:read
,
template:insert
Template listing, rendering, insertion
plugins
plugins
,
plugin
,
plugin:enable
,
plugin:disable
,
plugin:install
,
plugin:uninstall
,
plugins:restrict
Plugin management
sync
sync
,
sync:status
,
sync:history
,
sync:read
,
sync:restore
,
sync:deleted
Obsidian Sync operations
themes
themes
,
theme
,
theme:set
,
theme:install
,
theme:uninstall
Theme management
snippets
snippets
,
snippets:enabled
,
snippet:enable
,
snippet:disable
CSS snippet management
commands
commands
,
command
,
hotkeys
,
hotkey
Execute Obsidian commands by ID; inspect hotkeys
bases
bases
,
base:query
,
base:views
,
base:create
Obsidian Bases (v1.12+ database feature)
history
history
,
history:list
,
history:read
,
history:restore
File version recovery (File Recovery plugin)
workspace
workspace
,
tabs
,
tab:open
Workspace layout and tab management
diff
diff
Compare local vs sync file versions
dev
eval
,
dev:screenshot
,
dev:debug
,
dev:console
,
dev:errors
,
dev:css
,
dev:dom
,
devtools
Developer/debugging tools
vault
vault
,
vaults
,
version
,
reload
,
restart
Vault info and app control
other
outline
,
wordcount
,
recents
Utility commands
CLI提供130+命令,归属以下分组:
分组核心命令用途
files
read
,
create
,
append
,
prepend
,
move
,
rename
,
delete
,
files
,
folders
,
file
,
random
笔记增删改查与文件检索
daily
daily
,
daily:read
,
daily:append
,
daily:prepend
,
daily:path
每日笔记操作
search
search
,
search:context
全文搜索;
search:context
会返回匹配的行内容
properties
properties
,
property:read
,
property:set
,
property:remove
,
aliases
Frontmatter/元数据管理
tags
tags
,
tag
标签列表、统计与筛选
tasks
tasks
,
task
任务查询、筛选与状态切换
links
backlinks
,
links
,
unresolved
,
orphans
,
deadends
关系图与链接分析
bookmarks
bookmarks
,
bookmark
书签列表与添加
templates
templates
,
template:read
,
template:insert
模板列表、渲染与插入
plugins
plugins
,
plugin
,
plugin:enable
,
plugin:disable
,
plugin:install
,
plugin:uninstall
,
plugins:restrict
插件管理
sync
sync
,
sync:status
,
sync:history
,
sync:read
,
sync:restore
,
sync:deleted
Obsidian Sync操作
themes
themes
,
theme
,
theme:set
,
theme:install
,
theme:uninstall
主题管理
snippets
snippets
,
snippets:enabled
,
snippet:enable
,
snippet:disable
CSS片段管理
commands
commands
,
command
,
hotkeys
,
hotkey
按ID执行Obsidian命令;查询快捷键
bases
bases
,
base:query
,
base:views
,
base:create
Obsidian Bases(v1.12+新增的数据库功能)
history
history
,
history:list
,
history:read
,
history:restore
文件版本恢复(依赖文件恢复插件)
workspace
workspace
,
tabs
,
tab:open
工作区布局与标签页管理
diff
diff
对比本地与同步端的文件版本
dev
eval
,
dev:screenshot
,
dev:debug
,
dev:console
,
dev:errors
,
dev:css
,
dev:dom
,
devtools
开发者/调试工具
vault
vault
,
vaults
,
version
,
reload
,
restart
vault信息与应用控制
other
outline
,
wordcount
,
recents
实用工具命令

Quick Reference — Most Common Commands

快速参考——最常用命令

Reading & Writing Notes

读写笔记

bash
obsidian read path="folder/note.md"
obsidian create path="folder/note" content="# New Note"
obsidian create path="folder/note" template="meeting-notes"
obsidian append path="folder/note.md" content="New paragraph"
obsidian prepend path="folder/note.md" content="Top content"
obsidian move path="old/note.md" to="new/note.md"
obsidian delete path="folder/note.md"
obsidian delete path="folder/note.md" permanent
bash
obsidian read path="folder/note.md"
obsidian create path="folder/note" content="# New Note"
obsidian create path="folder/note" template="meeting-notes"
obsidian append path="folder/note.md" content="New paragraph"
obsidian prepend path="folder/note.md" content="Top content"
obsidian move path="old/note.md" to="new/note.md"
obsidian delete path="folder/note.md"
obsidian delete path="folder/note.md" permanent

Daily Notes

每日笔记

bash
obsidian daily                          # Open today's daily note
obsidian daily:read                     # Print content of today's note
obsidian daily:append content="- [ ] New task"
obsidian daily:prepend content="## Morning Notes"
bash
obsidian daily                          # 打开今日的每日笔记
obsidian daily:read                     # 打印今日笔记的内容
obsidian daily:append content="- [ ] New task"
obsidian daily:prepend content="## Morning Notes"

Search

搜索

bash
obsidian search query="project alpha"
obsidian search query="TODO" path="projects" limit=10
obsidian search query="meeting" format=json   # Returns JSON array of file paths
obsidian search query="urgent" case
bash
obsidian search query="project alpha"
obsidian search query="TODO" path="projects" limit=10
obsidian search query="meeting" format=json   # 返回文件路径的JSON数组
obsidian search query="urgent" case

Properties & Tags

属性与标签

bash
obsidian properties path="note.md"
obsidian property:set path="note.md" name="status" value="active"
obsidian property:read path="note.md" name="status"
obsidian property:remove path="note.md" name="draft"
obsidian tags counts sort=count
obsidian tag name="project/alpha"
bash
obsidian properties path="note.md"
obsidian property:set path="note.md" name="status" value="active"
obsidian property:read path="note.md" name="status"
obsidian property:remove path="note.md" name="draft"
obsidian tags counts sort=count
obsidian tag name="project/alpha"

Tasks

任务

bash
obsidian tasks                          # All tasks (done + todo) — same as tasks all in v1.12
obsidian tasks all                      # All tasks (done + todo)
obsidian tasks done                     # Completed only
obsidian tasks daily                    # Tasks in today's daily note
obsidian task path="note.md" line=12 toggle
obsidian tasks | grep "\[ \]"           # Workaround: filter to incomplete only
bash
obsidian tasks                          # 所有任务(已完成+待办)——与v1.12中的tasks all等价
obsidian tasks all                      # 所有任务(已完成+待办)
obsidian tasks done                     # 仅已完成任务
obsidian tasks daily                    # 今日每日笔记中的任务
obsidian task path="note.md" line=12 toggle
obsidian tasks | grep "\[ \]"           # 变通方案:仅筛选未完成的任务

Developer & Automation

开发者与自动化

bash
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path="folder/screenshot.png"  # Path must be vault-relative
obsidian dev:debug on                                 # Required before dev:console
obsidian dev:console limit=20
obsidian dev:errors
bash
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path="folder/screenshot.png"  # 路径必须是vault相对路径
obsidian dev:debug on                                 # 运行dev:console前必须开启
obsidian dev:console limit=20
obsidian dev:errors

TUI Mode

TUI模式

Running
obsidian
with no arguments launches an interactive TUI (Terminal User Interface):
KeyAction
↑↓
Navigate files
Enter
Open file
/
Search
n
Create new file
d
Delete file
r
Rename file
q
Quit
不带任何参数运行
obsidian
会启动交互式TUI(终端用户界面):
按键操作
↑↓
浏览文件
Enter
打开文件
/
搜索
n
新建文件
d
删除文件
r
重命名文件
q
退出

Common Agent Patterns

常见Agent使用场景

Daily Journal Automation

每日日志自动化

bash
undefined
bash
undefined

Append a timestamped entry

追加带时间戳的日志条目

obsidian daily:append content="## $(date '+%H:%M') — Status Update
  • Completed: feature branch merge
  • Next: code review for PR #42
  • Blocked: waiting on API credentials"
undefined
obsidian daily:append content="## $(date '+%H:%M') — Status Update
  • Completed: feature branch merge
  • Next: code review for PR #42
  • Blocked: waiting on API credentials"
undefined

Create Note from Template with Metadata

基于模板创建带元数据的笔记

bash
obsidian create path="projects/new-feature" template="project-template"
obsidian property:set path="projects/new-feature.md" name="status" value="planning"
obsidian property:set path="projects/new-feature.md" name="created" value="$(date -I)"
obsidian daily:append content="- Started [[projects/new-feature|New Feature]]"
bash
obsidian create path="projects/new-feature" template="project-template"
obsidian property:set path="projects/new-feature.md" name="status" value="planning"
obsidian property:set path="projects/new-feature.md" name="created" value="$(date -I)"
obsidian daily:append content="- Started [[projects/new-feature|New Feature]]"

Vault Analytics Script

Vault分析脚本

bash
obsidian files total                    # Total file count
obsidian tags counts sort=count         # Most used tags
obsidian tasks | grep "\[ \]"          # Incomplete tasks across vault
obsidian orphans                        # Notes needing integration
obsidian unresolved                     # Broken links to fix
bash
obsidian files total                    # 总文件数
obsidian tags counts sort=count         # 使用频次最高的标签
obsidian tasks | grep "\[ \]"          # 整个vault中的未完成任务
obsidian orphans                        # 需要关联的孤立笔记
obsidian unresolved                     # 需要修复的失效链接

Search and Extract for AI Processing

搜索提取内容用于AI处理

bash
obsidian search query="meeting notes" format=json | jq '.[]'
obsidian read path="meetings/standup.md" | grep "Action item"
bash
obsidian search query="meeting notes" format=json | jq '.[]'
obsidian read path="meetings/standup.md" | grep "Action item"

Sync Management

同步管理

bash
obsidian sync:status                    # Check sync health
obsidian sync:history path="important.md"  # Version history
obsidian sync:restore path="important.md" version=3  # Rollback
bash
obsidian sync:status                    # 检查同步状态
obsidian sync:history path="important.md"  # 版本历史
obsidian sync:restore path="important.md" version=3  # 回滚版本

Execute Obsidian Commands

执行Obsidian命令

bash
undefined
bash
undefined

Find a command ID, then execute it

查找命令ID,然后执行

obsidian commands | grep "graph" obsidian command id="graph:open"
obsidian commands | grep "graph" obsidian command id="graph:open"

Open settings, trigger a plugin action

打开设置,触发插件操作

obsidian command id="app:open-settings" obsidian command id="dataview:dataview-force-refresh-views"
undefined
obsidian command id="app:open-settings" obsidian command id="dataview:dataview-force-refresh-views"
undefined

Tips

使用提示

  1. Paths are vault-relative — use
    folder/note.md
    , not absolute filesystem paths.
  2. create
    paths omit
    .md
    — the extension is added automatically.
  3. move
    requires full target path
    including
    .md
    extension.
  4. Pipe-friendly — plain text output works with
    grep
    ,
    awk
    ,
    sed
    ,
    jq
    .
  5. JSON output — use
    format=json
    on
    search
    for a JSON array of file paths. The
    files
    command does not support JSON output.
  6. Stderr noise — GPU/Electron warnings on headless are harmless; filter with
    2>/dev/null
    .
  7. daily:prepend
    inserts content after frontmatter, not at byte 0.
  8. Use
    eval
    to run arbitrary JavaScript against the Obsidian API (
    app.*
    ).
  9. template:insert
    inserts into the currently active file in the Obsidian UI — it does not accept a
    path=
    parameter. If no file is open, it returns
    Error: No active editor. Open a file first.
    To create a file from a template via CLI, use
    obsidian create path="..." template="..."
    instead.
  10. property:set
    stores list values as strings
    value="tag1, tag2"
    writes a literal comma-separated string, not a YAML array. For proper array fields, edit the note's frontmatter directly (e.g. via
    read
    → modify →
    create --force
    ) or use
    eval
    to call the Obsidian API.
  11. eval
    requires single-line JavaScript
    — multiline JS passed inline fails with a token error. Write the script to a temp file instead:
    bash
    cat > /tmp/obs.js << 'JS'
    var files = app.vault.getMarkdownFiles();
    files.length;
    JS
    obsidian eval code="$(cat /tmp/obs.js)"
  12. Multi-vault targeting may not work in all environments
    obsidian "My Vault" command
    can return
    Error: Command "My Vault" not found
    on some setups. If this happens, omit the vault name (CLI targets the most recently active vault) and switch vaults manually in the Obsidian UI.
  13. When colon subcommands are unavailable (e.g. Windows Git Bash without wrapper), prefer non-colon alternatives: use
    properties
    instead of
    property:read
    , and
    obsidian daily:path
    +
    append
    instead of
    daily:append
    .
  1. 路径为vault相对路径——使用
    folder/note.md
    格式,不要用绝对文件系统路径。
  2. create
    命令的路径省略
    .md
    ——扩展名会自动添加。
  3. move
    命令需要完整的目标路径
    ,包含
    .md
    扩展名。
  4. 支持管道操作——纯文本输出可与
    grep
    awk
    sed
    jq
    配合使用。
  5. JSON输出——
    search
    命令使用
    format=json
    参数可返回文件路径的JSON数组,
    files
    命令不支持JSON输出。
  6. Stderr冗余输出——无界面环境下的GPU/Electron警告无危害,可通过
    2>/dev/null
    过滤。
  7. **
    daily:prepend
    **会将内容插入到Frontmatter之后,而非文件最开头。
  8. **使用
    eval
    **可基于Obsidian API(
    app.*
    )运行任意JavaScript代码。
  9. **
    template:insert
    **会插入到Obsidian UI中当前激活的文件里——不支持
    path=
    参数。如果没有打开的文件,会返回
    Error: No active editor. Open a file first.
    。如果需要通过CLI基于模板创建文件,请使用
    obsidian create path="..." template="..."
  10. property:set
    会将列表值存储为字符串
    ——
    value="tag1, tag2"
    会写入字面量的逗号分隔字符串,而非YAML数组。如果需要正确的数组字段,请直接编辑笔记的Frontmatter(例如通过
    read
    →修改→
    create --force
    的流程),或者使用
    eval
    调用Obsidian API。
  11. eval
    要求JavaScript为单行
    ——内联传入多行JS会报错token错误。请将脚本写入临时文件再调用:
    bash
    cat > /tmp/obs.js << 'JS'
    var files = app.vault.getMarkdownFiles();
    files.length;
    JS
    obsidian eval code="$(cat /tmp/obs.js)"
  12. 多vault指定可能在部分环境下失效——部分配置中
    obsidian "My Vault" command
    会返回
    Error: Command "My Vault" not found
    。如果出现该问题,请省略vault名称(CLI会操作最近激活的vault),并手动在Obsidian UI中切换vault。
  13. 冒号子命令不可用时(例如Windows Git Bash没有配置包装脚本),优先使用非冒号替代方案:用
    properties
    代替
    property:read
    ,用
    obsidian daily:path
    +
    append
    代替
    daily:append

Troubleshooting

故障排除

ProblemCauseFix
Empty output / hangsObsidian not running, or admin terminal (Windows)Start Obsidian; use normal-privilege terminal
Command not foundCLI not registered in PATHRe-enable CLI in Settings; restart terminal
Unicode errorsFixed in v1.12.2+Update Obsidian
Wrong vault targetedMulti-vault ambiguityPass vault name as first arg
IPC socket not found (Linux)
PrivateTmp=true
in systemd
Set
PrivateTmp=false
Snap confinement issuesSnap restricts IPCUse
.deb
package instead
Multi-vault
"Name" command
fails
Vault name matching issueOmit vault name; target most recent vault
property:set
list value is a string
CLI stores value as-isEdit frontmatter directly or use
eval
Colon+params exit 127 (missing
.com
)
Outdated installer —
Obsidian.com
absent
Reinstall from obsidian.md/download
Colon+params exit 127 (Git Bash / MSYS2)Bash resolves
obsidian
to
.exe
not
.com
Create
~/bin/obsidian
wrapper:
#!/bin/bash
/
/c/path/to/Obsidian.com "$@"
and add
export PATH="$HOME/bin:$PATH"
to
~/.bashrc
问题原因解决方案
输出为空 / 命令挂起Obsidian未运行,或者使用了管理员终端(Windows)启动Obsidian;使用普通权限的终端
命令未找到CLI未注册到PATH中在设置中重新启用CLI功能;重启终端
Unicode错误v1.12.2+版本已修复该问题升级Obsidian
操作了错误的vault多vault场景下的歧义将vault名称作为第一个参数传入
找不到IPC socket(Linux)systemd配置中
PrivateTmp=true
设置
PrivateTmp=false
Snap权限限制问题Snap限制了IPC通信改用
.deb
安装包
多vault命令
"名称" command
失败
vault名称匹配问题省略vault名称,操作最近激活的vault
property:set
设置的列表值变为字符串
CLI会原样存储传入的值直接编辑Frontmatter或使用
eval
冒号+参数命令返回退出码127(缺失
.com
文件)
安装包过旧,
Obsidian.com
不存在
obsidian.md/download重新安装
冒号+参数命令返回退出码127(Git Bash / MSYS2)Bash将
obsidian
解析为
.exe
而非
.com
创建
~/bin/obsidian
包装脚本:
#!/bin/bash
/
/c/path/to/Obsidian.com "$@"
,并将
export PATH="$HOME/bin:$PATH"
添加到
~/.bashrc