Obsidian CLI
Official command-line interface for Obsidian. Anything you can do in Obsidian can be done from the command line — including developer commands for debugging, screenshots, and plugin reloading.
Prerequisites
- - Obsidian 1.12+ and Catalyst license required
- Settings → General → Command line interface → Enable
- Follow prompt to register the
obsidian command - Restart terminal or
source ~/.zprofile (macOS) - Note: Obsidian must be running for CLI to work
Test setup: INLINECODE2
Core Patterns
Command Structure
CODEBLOCK0
Parameter Types
- - Parameters:
name=value (quote values with spaces) - Flags: Boolean switches (just include to enable)
- Multiline: Use
for newlines, \t for tabs - Copy output: Add
--copy to copy to clipboard
File Operations
Basic File Management
CODEBLOCK1
File Targeting
- -
file=<name> — Wikilink resolution (matches by name) - INLINECODE8 — Exact path from vault root
Search and Discovery
Text Search
CODEBLOCK2
Tags and Properties
CODEBLOCK3
Links and Structure
CODEBLOCK4
Daily Notes and Tasks
Daily Notes
CODEBLOCK5
Task Management
CODEBLOCK6
Templates and Bookmarks
Templates
CODEBLOCK7
Bookmarks
CODEBLOCK8
Plugin and Theme Management
Plugins
CODEBLOCK9
Themes and CSS
CODEBLOCK10
Advanced Features
Obsidian Sync
CODEBLOCK11
File History
CODEBLOCK12
Developer Tools
CODEBLOCK13
Utility Commands
Workspace and Navigation
CODEBLOCK14
Command Palette
CODEBLOCK15
TUI Mode
Interactive terminal UI with enhanced features:
CODEBLOCK16
TUI Shortcuts:
- - Navigation: ←/→ (Ctrl+B/F), Home/End (Ctrl+A/E)
- Editing: Ctrl+U (delete to start), Ctrl+K (delete to end)
- Autocomplete: Tab/↓ (enter), Shift+Tab/Esc (exit)
- History: ↑/↓ (Ctrl+P/N), Ctrl+R (reverse search)
- Other: Enter (execute), Ctrl+L (clear), Ctrl+C/D (exit)
Troubleshooting
Setup Issues
- - Use latest installer (1.11.7+) with early access (1.12.x)
- Restart terminal after CLI registration
- Ensure Obsidian is running before using CLI
Platform-Specific
macOS: PATH added to ~/.zprofile
CODEBLOCK17
Linux: Symlink at /usr/local/bin/obsidian
CODEBLOCK18
Windows: Requires Obsidian.com terminal redirector (Catalyst Discord)
Obsidian CLI
Obsidian的官方命令行界面。在Obsidian中能做的任何事情都可以通过命令行完成——包括用于调试、截图和插件重载的开发者命令。
前置条件
- - 需要 Obsidian 1.12+ 和 Catalyst许可证
- 设置 → 通用 → 命令行界面 → 启用
- 按照提示注册 obsidian 命令
- 重启终端或执行 source ~/.zprofile(macOS)
- 注意: CLI运行时Obsidian必须处于运行状态
测试设置:obsidian version
核心模式
命令结构
bash
单条命令
obsidian
[parameters] [flags]
TUI模式(交互式)
obsidian # 进入带自动补全和历史记录的TUI
指定仓库
obsidian vault=Notes
obsidian vault=My Vault
参数类型
- - 参数: name=value(带空格的值需加引号)
- 标志: 布尔开关(直接包含即可启用)
- 多行: 使用 表示换行,\t 表示制表符
- 复制输出: 添加 --copy 复制到剪贴板
文件操作
基本文件管理
bash
信息与列表
obsidian file # 当前文件信息
obsidian file file=Recipe # 指定文件信息
obsidian files # 列出所有文件
obsidian files folder=Projects/ # 按文件夹筛选
obsidian folders # 列出文件夹
打开与读取
obsidian open file=Recipe # 打开文件
obsidian open path=Inbox/Note.md newtab
obsidian read # 读取当前文件
obsidian read file=Recipe --copy # 读取并复制到剪贴板
创建新笔记
obsidian create name=New Note
obsidian create name=Note content=# Title Body
obsidian create path=Inbox/Idea.md template=Daily
obsidian create name=Note silent overwrite
修改内容
obsidian append file=Note content=New line
obsidian append file=Note content=Same line inline
obsidian prepend file=Note content=After frontmatter
移动与删除
obsidian move file=Note to=Archive/
obsidian move path=Inbox/Old.md to=Projects/New.md
obsidian delete file=Note # 移至回收站
obsidian delete file=Note permanent
文件定位
- - file= — Wiki链接解析(按名称匹配)
- path= — 从仓库根目录开始的精确路径
搜索与发现
文本搜索
bash
obsidian search query=meeting notes
obsidian search query=TODO matches # 显示上下文
obsidian search query=project path=Projects/
obsidian search query=urgent limit=10 case
obsidian search query=API format=json
obsidian search:open query=search term # 在Obsidian中打开
标签与属性
bash
标签
obsidian tags # 当前文件标签
obsidian tags all # 所有仓库标签
obsidian tags all counts sort=count # 按频率排序
obsidian tag name=project # 标签信息
属性(frontmatter)
obsidian properties file=Note
obsidian property:read name=status file=Note
obsidian property:set name=status value=done file=Note
obsidian property:set name=tags value=a,b,c type=list file=Note
obsidian property:remove name=draft file=Note
链接与结构
bash
反向链接与出链
obsidian backlinks file=Note # 链接到此的内容
obsidian links file=Note # 出链
仓库分析
obsidian orphans # 无入链
obsidian deadends # 无出链
obsidian unresolved # 损坏链接
obsidian unresolved verbose counts
日记与任务
日记
bash
obsidian daily # 打开今日笔记
obsidian daily paneType=split # 分屏打开
obsidian daily:read # 打印内容
obsidian daily:append content=- [ ] New task
obsidian daily:prepend content=## Morning
任务管理
bash
列出任务
obsidian tasks # 当前文件
obsidian tasks all # 所有仓库任务
obsidian tasks all todo # 仅未完成
obsidian tasks file=Recipe # 指定文件
obsidian tasks daily # 日记任务
更新任务
obsidian task ref=Recipe.md:8 toggle
obsidian task file=Recipe line=8 done
obsidian task file=Recipe line=8 todo
obsidian task file=Note line=5 status=- # 自定义[-]
模板与书签
模板
bash
obsidian templates # 列出所有模板
obsidian template:read name=Daily
obsidian template:read name=Daily resolve title=My Note
obsidian template:insert name=Daily # 插入到当前文件
obsidian create name=Meeting Notes template=Meeting
书签
bash
obsidian bookmarks # 列出所有
obsidian bookmark file=Important.md
obsidian bookmark file=Note subpath=#Section
obsidian bookmark folder=Projects/
obsidian bookmark search=TODO
obsidian bookmark url=https://... title=Reference
插件与主题管理
插件
bash
列出与信息
obsidian plugins # 所有已安装
obsidian plugins:enabled # 仅已启用
obsidian plugin id=dataview # 插件信息
管理插件
obsidian plugin:enable id=dataview
obsidian plugin:disable id=dataview
obsidian plugin:install id=dataview enable
obsidian plugin:uninstall id=dataview
obsidian plugin:reload id=my-plugin # 开发用
主题与CSS
bash
主题
obsidian themes # 列出已安装
obsidian theme # 当前主题
obsidian theme:set name=Minimal
obsidian theme:install name=Theme Name enable
CSS片段
obsidian snippets # 列出所有
obsidian snippet:enable name=my-snippet
obsidian snippet:disable name=my-snippet
高级功能
Obsidian同步
bash
obsidian sync:status # 状态与用量
obsidian sync on/off # 恢复/暂停
obsidian sync:history file=Note
obsidian sync:restore file=Note version=2
obsidian sync:deleted # 已删除文件
文件历史
bash
obsidian history file=Note # 列出版本
obsidian history:read file=Note version=1
obsidian history:restore file=Note version=2
obsidian diff file=Note from=2 to=1 # 比较版本
开发者工具
bash
控制台与调试
obsidian devtools # 切换开发者工具
obsidian dev:console # 显示控制台
obsidian dev:errors # JS错误
obsidian eval code=app.vault.getFiles().length
截图与DOM
obsidian dev:screenshot path=screenshot.png
obsidian dev:dom selector=.workspace-leaf
obsidian dev:css selector=.mod-active prop=background
移动端与调试
obsidian dev:mobile on/off
obsidian dev:debug on/off
实用命令
工作区与导航
bash
工作区管理
obsidian workspace # 当前布局
obsidian workspace:save name=coding
obsidian workspace:load name=coding
obsidian tabs # 打开的标签页
obsidian tab:open file=Note
随机与唯一
obsidian random # 打开随机笔记
obsidian random folder=Inbox newtab
obsidian unique # 创建唯一名称
obsidian wordcount file=Note # 字数统计
命令面板
bash
obsidian commands # 列出所有命令ID
obsidian commands filter=editor # 筛选命令
obsidian command id=editor:toggle-bold
obsidian hotkeys # 列出快捷键
TUI模式
增强功能的交互式终端界面:
bash
obsidian # 进入TUI模式
TUI快捷键:
- - 导航: ←/→ (Ctrl+B/F), Home/End (Ctrl+A/E)
- 编辑: Ctrl+U (删除到开头), Ctrl+K (删除到结尾)
- 自动补全: Tab/↓ (进入), Shift