obsidian-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian 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.
Readwhen 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.references/command-reference.md
官方Obsidian CLI(2026年2月随v1.12版本发布)支持你通过终端控制Obsidian的所有功能,它通过IPC与运行中的Obsidian桌面端实例通信。
如果你需要查询任意命令组的特定参数、输出格式或子命令,请查阅。该文档覆盖了全部130+命令的完整参数表,顶部附有目录。references/command-reference.md
Prerequisites
前置条件
| Requirement | Details |
|---|---|
| Obsidian Desktop | v1.12.0+ |
| CLI enabled | Settings → Command line interface → Toggle ON |
| Obsidian running | The desktop app must be running for CLI to work (IPC) |
| 要求 | 详情 |
|---|---|
| Obsidian桌面端 | v1.12.0及以上版本 |
| 启用CLI功能 | 设置 → 命令行界面 → 开启开关 |
| Obsidian处于运行状态 | 桌面应用必须处于运行状态CLI才能正常工作(依赖IPC通信) |
Platform Notes
平台注意事项
- macOS / Linux: The binary is registered in PATH automatically when you enable CLI in settings.
obsidian - Windows: Requires an redirector file placed alongside
Obsidian.com. Must run with normal user privileges — admin terminals produce silent failures.Obsidian.exe- If colon subcommands (,
property:set, etc.) with parameters return exit 127, check thatdaily:appendexists alongsideObsidian.com. If missing, you have an outdated installer — download the latest from obsidian.md/download and reinstall.Obsidian.exe - Git Bash / MSYS2 users: Bash resolves to
obsidian(GUI) instead ofObsidian.exe(CLI), causing colon+params to fail with exit 127 even whenObsidian.comis present. Create a wrapper script — see Troubleshooting.Obsidian.com
- If colon subcommands (
- Headless Linux: Use the package (not snap). Run under
.deb. Prefix commands withxvfb(or your xvfb display number). EnsureDISPLAY=:5if running as a service.PrivateTmp=false
- macOS / Linux: 你在设置中启用CLI功能后,二进制文件会自动注册到PATH中。
obsidian - Windows: 需要在同级目录下放置
Obsidian.exe重定向文件。必须使用普通用户权限运行——管理员终端会出现无提示的失败问题。Obsidian.com- 如果带参数的冒号子命令(、
property:set等)返回退出码127,请检查daily:append同级目录下是否存在Obsidian.exe。如果缺失说明你的安装包版本过旧,请从obsidian.md/download下载最新版本重新安装。Obsidian.com - Git Bash / MSYS2用户: Bash会将解析为
obsidian(GUI程序)而非Obsidian.exe(CLI程序),即便Obsidian.com存在,冒号+参数的命令也会失败并返回退出码127。请创建一个包装脚本,详见故障排除部分。Obsidian.com
- 如果带参数的冒号子命令(
- 无界面Linux: 使用安装包(不要用snap包),在
.deb环境下运行,命令前添加前缀xvfb(替换为你的xvfb显示编号)。如果以服务运行,请确保DISPLAY=:5。PrivateTmp=false
Syntax
语法
All parameters use syntax. Quote values containing spaces.
key=valuebash
obsidian <command> [subcommand] [key=value ...] [flags]所有参数使用****语法,包含空格的参数值需要加引号。
key=valuebash
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:
| Group | Key Commands | Purpose |
|---|---|---|
| files | | Note CRUD and file discovery |
| daily | | Daily note operations |
| search | | Full-text search; |
| properties | | Frontmatter/metadata management |
| tags | | Tag listing, counts, and filtering |
| tasks | | Task querying, filtering, and toggling |
| links | | Graph and link analysis |
| bookmarks | | List and add bookmarks |
| templates | | Template listing, rendering, insertion |
| plugins | | Plugin management |
| sync | | Obsidian Sync operations |
| themes | | Theme management |
| snippets | | CSS snippet management |
| commands | | Execute Obsidian commands by ID; inspect hotkeys |
| bases | | Obsidian Bases (v1.12+ database feature) |
| history | | File version recovery (File Recovery plugin) |
| workspace | | Workspace layout and tab management |
| diff | | Compare local vs sync file versions |
| dev | | Developer/debugging tools |
| vault | | Vault info and app control |
| other | | Utility commands |
CLI提供130+命令,归属以下分组:
| 分组 | 核心命令 | 用途 |
|---|---|---|
| files | | 笔记增删改查与文件检索 |
| daily | | 每日笔记操作 |
| search | | 全文搜索; |
| properties | | Frontmatter/元数据管理 |
| tags | | 标签列表、统计与筛选 |
| tasks | | 任务查询、筛选与状态切换 |
| links | | 关系图与链接分析 |
| bookmarks | | 书签列表与添加 |
| templates | | 模板列表、渲染与插入 |
| plugins | | 插件管理 |
| sync | | Obsidian Sync操作 |
| themes | | 主题管理 |
| snippets | | CSS片段管理 |
| commands | | 按ID执行Obsidian命令;查询快捷键 |
| bases | | Obsidian Bases(v1.12+新增的数据库功能) |
| history | | 文件版本恢复(依赖文件恢复插件) |
| workspace | | 工作区布局与标签页管理 |
| diff | | 对比本地与同步端的文件版本 |
| dev | | 开发者/调试工具 |
| vault | | vault信息与应用控制 |
| other | | 实用工具命令 |
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" permanentbash
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" permanentDaily 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" casebash
obsidian search query="project alpha"
obsidian search query="TODO" path="projects" limit=10
obsidian search query="meeting" format=json # 返回文件路径的JSON数组
obsidian search query="urgent" caseProperties & 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 onlybash
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:errorsbash
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:errorsTUI Mode
TUI模式
Running with no arguments launches an interactive TUI (Terminal User Interface):
obsidian| Key | Action |
|---|---|
| Navigate files |
| Open file |
| Search |
| Create new file |
| Delete file |
| Rename file |
| Quit |
不带任何参数运行会启动交互式TUI(终端用户界面):
obsidian| 按键 | 操作 |
|---|---|
| 浏览文件 |
| 打开文件 |
| 搜索 |
| 新建文件 |
| 删除文件 |
| 重命名文件 |
| 退出 |
Common Agent Patterns
常见Agent使用场景
Daily Journal Automation
每日日志自动化
bash
undefinedbash
undefinedAppend 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"
undefinedobsidian daily:append content="## $(date '+%H:%M') — Status Update
- Completed: feature branch merge
- Next: code review for PR #42
- Blocked: waiting on API credentials"
undefinedCreate 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 fixbash
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 # Rollbackbash
obsidian sync:status # 检查同步状态
obsidian sync:history path="important.md" # 版本历史
obsidian sync:restore path="important.md" version=3 # 回滚版本Execute Obsidian Commands
执行Obsidian命令
bash
undefinedbash
undefinedFind 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"
undefinedobsidian command id="app:open-settings"
obsidian command id="dataview:dataview-force-refresh-views"
undefinedTips
使用提示
- Paths are vault-relative — use , not absolute filesystem paths.
folder/note.md - paths omit
create— the extension is added automatically..md - requires full target path including
moveextension..md - Pipe-friendly — plain text output works with ,
grep,awk,sed.jq - JSON output — use on
format=jsonfor a JSON array of file paths. Thesearchcommand does not support JSON output.files - Stderr noise — GPU/Electron warnings on headless are harmless; filter with .
2>/dev/null - inserts content after frontmatter, not at byte 0.
daily:prepend - Use to run arbitrary JavaScript against the Obsidian API (
eval).app.* - inserts into the currently active file in the Obsidian UI — it does not accept a
template:insertparameter. If no file is open, it returnspath=To create a file from a template via CLI, useError: No active editor. Open a file first.instead.obsidian create path="..." template="..." - stores list values as strings —
property:setwrites a literal comma-separated string, not a YAML array. For proper array fields, edit the note's frontmatter directly (e.g. viavalue="tag1, tag2"→ modify →read) or usecreate --forceto call the Obsidian API.eval - requires single-line JavaScript — multiline JS passed inline fails with a token error. Write the script to a temp file instead:
evalbashcat > /tmp/obs.js << 'JS' var files = app.vault.getMarkdownFiles(); files.length; JS obsidian eval code="$(cat /tmp/obs.js)" - Multi-vault targeting may not work in all environments — can return
obsidian "My Vault" commandon some setups. If this happens, omit the vault name (CLI targets the most recently active vault) and switch vaults manually in the Obsidian UI.Error: Command "My Vault" not found - When colon subcommands are unavailable (e.g. Windows Git Bash without wrapper), prefer non-colon alternatives: use instead of
properties, andproperty:read+obsidian daily:pathinstead ofappend.daily:append
- 路径为vault相对路径——使用格式,不要用绝对文件系统路径。
folder/note.md - 命令的路径省略
create——扩展名会自动添加。.md - 命令需要完整的目标路径,包含
move扩展名。.md - 支持管道操作——纯文本输出可与、
grep、awk、sed配合使用。jq - JSON输出——命令使用
search参数可返回文件路径的JSON数组,format=json命令不支持JSON输出。files - Stderr冗余输出——无界面环境下的GPU/Electron警告无危害,可通过过滤。
2>/dev/null - ****会将内容插入到Frontmatter之后,而非文件最开头。
daily:prepend - **使用**可基于Obsidian API(
eval)运行任意JavaScript代码。app.* - ****会插入到Obsidian UI中当前激活的文件里——不支持
template:insert参数。如果没有打开的文件,会返回path=。如果需要通过CLI基于模板创建文件,请使用Error: No active editor. Open a file first.。obsidian create path="..." template="..." - 会将列表值存储为字符串——
property:set会写入字面量的逗号分隔字符串,而非YAML数组。如果需要正确的数组字段,请直接编辑笔记的Frontmatter(例如通过value="tag1, tag2"→修改→read的流程),或者使用create --force调用Obsidian API。eval - 要求JavaScript为单行——内联传入多行JS会报错token错误。请将脚本写入临时文件再调用:
evalbashcat > /tmp/obs.js << 'JS' var files = app.vault.getMarkdownFiles(); files.length; JS obsidian eval code="$(cat /tmp/obs.js)" - 多vault指定可能在部分环境下失效——部分配置中会返回
obsidian "My Vault" command。如果出现该问题,请省略vault名称(CLI会操作最近激活的vault),并手动在Obsidian UI中切换vault。Error: Command "My Vault" not found - 冒号子命令不可用时(例如Windows Git Bash没有配置包装脚本),优先使用非冒号替代方案:用代替
properties,用property:read+obsidian daily:path代替append。daily:append
Troubleshooting
故障排除
| Problem | Cause | Fix |
|---|---|---|
| Empty output / hangs | Obsidian not running, or admin terminal (Windows) | Start Obsidian; use normal-privilege terminal |
| Command not found | CLI not registered in PATH | Re-enable CLI in Settings; restart terminal |
| Unicode errors | Fixed in v1.12.2+ | Update Obsidian |
| Wrong vault targeted | Multi-vault ambiguity | Pass vault name as first arg |
| IPC socket not found (Linux) | | Set |
| Snap confinement issues | Snap restricts IPC | Use |
Multi-vault | Vault name matching issue | Omit vault name; target most recent vault |
| CLI stores value as-is | Edit frontmatter directly or use |
Colon+params exit 127 (missing | Outdated installer — | Reinstall from obsidian.md/download |
| Colon+params exit 127 (Git Bash / MSYS2) | Bash resolves | Create |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 输出为空 / 命令挂起 | Obsidian未运行,或者使用了管理员终端(Windows) | 启动Obsidian;使用普通权限的终端 |
| 命令未找到 | CLI未注册到PATH中 | 在设置中重新启用CLI功能;重启终端 |
| Unicode错误 | v1.12.2+版本已修复该问题 | 升级Obsidian |
| 操作了错误的vault | 多vault场景下的歧义 | 将vault名称作为第一个参数传入 |
| 找不到IPC socket(Linux) | systemd配置中 | 设置 |
| Snap权限限制问题 | Snap限制了IPC通信 | 改用 |
多vault命令 | vault名称匹配问题 | 省略vault名称,操作最近激活的vault |
| CLI会原样存储传入的值 | 直接编辑Frontmatter或使用 |
冒号+参数命令返回退出码127(缺失 | 安装包过旧, | 从obsidian.md/download重新安装 |
| 冒号+参数命令返回退出码127(Git Bash / MSYS2) | Bash将 | 创建 |