obsidian-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian CLI

Obsidian CLI

Run
obsidian <command>
to control Obsidian from the terminal. The app must be running for most commands; the first command will launch Obsidian if not open.
Run
obsidian help
or
obsidian help <command>
for the canonical, always-up-to-date command reference. This skill documents common patterns and non-obvious behaviors.
运行
obsidian <command>
从终端控制Obsidian。大多数命令要求应用处于运行状态;如果Obsidian未打开,第一条命令会启动它。
运行
obsidian help
obsidian help <command>
获取官方的、实时更新的命令参考。本技能文档记录了常见用法和非显而易见的特性。

Targeting vaults and files

定位库与文件

  • Vault:
    vault=<name>
    as first parameter. Default: cwd if it's a vault folder, else the active vault.
  • File:
    file=<name>
    resolves like a wikilink (name only, no path or extension needed).
    path=<path>
    for exact path from vault root.
  • TUI: Run
    obsidian
    with no args for interactive mode; omit the
    obsidian
    prefix inside.
  • 库(Vault):将
    vault=<name>
    作为第一个参数。默认值:如果当前工作目录是库文件夹则使用它,否则使用活动库。
  • 文件
    file=<name>
    像维基链接一样解析(仅需名称,无需路径或扩展名)。使用
    path=<path>
    指定从库根目录开始的精确路径。
  • TUI:不带参数运行
    obsidian
    进入交互模式;在交互模式内可省略
    obsidian
    前缀。

Parameters and flags

参数与标志

  • Parameters:
    param=value
    . Quote values with spaces:
    content="Hello world"
    .
  • Flags: Boolean, no value:
    silent
    ,
    overwrite
    ,
    newtab
    .
  • Multiline content: Use
    \n
    for newlines,
    \t
    for tabs in
    content=
    .
  • 参数:格式为
    param=value
    。包含空格的值需加引号:
    content="Hello world"
  • 标志:布尔型,无值,例如
    silent
    overwrite
    newtab
  • 多行内容:在
    content=
    中使用
    \n
    表示换行,
    \t
    表示制表符。

Search, links, and structure

搜索、链接与结构

bash
obsidian search query="text" [path=folder] [limit=n] [format=text|json] [total] [case]
obsidian search:context query="text" [path=folder] [limit=n]  # includes surrounding context
obsidian links [file=Note] [total]
obsidian backlinks [file=Note] [counts] [total]
obsidian outline [file=Note] [format=tree|md]
obsidian orphans [total] [active]       # notes with no links to or from them
obsidian deadends [total] [active]      # notes with no outgoing links
obsidian unresolved [total] [counts] [verbose]  # broken wikilinks
obsidian tags [active] [file=Note] [total] [counts] [sort=count]
obsidian tag name=project [total] [verbose]
bash
obsidian search query="text" [path=folder] [limit=n] [format=text|json] [total] [case]
obsidian search:context query="text" [path=folder] [limit=n]  # 包含上下文内容
obsidian links [file=Note] [total]
obsidian backlinks [file=Note] [counts] [total]
obsidian outline [file=Note] [format=tree|md]
obsidian orphans [total] [active]       # 无入站和出站链接的笔记
obsidian deadends [total] [active]      # 无出站链接的笔记
obsidian unresolved [total] [counts] [verbose]  # 失效的维基链接
obsidian tags [active] [file=Note] [total] [counts] [sort=count]
obsidian tag name=project [total] [verbose]

Common patterns

常见用法

Notes and content

笔记与内容

To peek at a note without reading its full content, use
property:read
or
properties file=Note
.
bash
obsidian read file="Note" # Use this to read the content of a wikilink
obsidian create name="Note" content="# Title\n\nBody" [template=Name] [overwrite] [silent]
obsidian append file="Note" content="- [ ] Task"
obsidian prepend file="Note" content="# Header\n"
obsidian move file="Note" to=folder/newpath.md
obsidian rename file="Note" name="New file name"
obsidian delete file="Note"
若无需查看完整内容即可快速查看笔记信息,可使用
property:read
properties file=Note
bash
obsidian read file="Note" # 用于读取维基链接指向的笔记内容
obsidian create name="Note" content="# Title\n\nBody" [template=Name] [overwrite] [silent]
obsidian append file="Note" content="- [ ] Task"
obsidian prepend file="Note" content="# Header\n"
obsidian move file="Note" to=folder/newpath.md
obsidian rename file="Note" name="New file name"
obsidian delete file="Note"

Daily notes (Daily notes plugin)

每日笔记(Daily notes 插件)

bash
obsidian daily:read
obsidian daily [paneType=tab|split|window] [open]
obsidian daily:append content="- [ ] Buy groceries" [inline] [open]
obsidian daily:prepend content="- [ ] Morning routine" [inline]  # goes after frontmatter
obsidian daily:path  # returns expected path even if file doesn't exist yet
bash
obsidian daily:read
obsidian daily [paneType=tab|split|window] [open]
obsidian daily:append content="- [ ] Buy groceries" [inline] [open]
obsidian daily:prepend content="- [ ] Morning routine" [inline]  # 插入在前置元数据之后
obsidian daily:path  # 即使文件尚未存在,也会返回预期路径

Tasks

任务

bash
obsidian tasks [daily] [file=Note] [todo] [done] [status="x"] [total] [verbose]
obsidian task ref=path:line [toggle] [done] [todo] [daily]
bash
obsidian tasks [daily] [file=Note] [todo] [done] [status="x"] [total] [verbose]
obsidian task ref=path:line [toggle] [done] [todo] [daily]

Properties and frontmatter

属性与前置元数据

bash
obsidian properties [active] [file=Note] [total] [counts] [format=yaml|json|tsv]
obsidian property:read name=status [file=Note]
obsidian property:set name=status value=done [file=Note]
obsidian property:remove name=status [file=Note]
bash
obsidian properties [active] [file=Note] [total] [counts] [format=yaml|json|tsv]
obsidian property:read name=status [file=Note]
obsidian property:set name=status value=done [file=Note]
obsidian property:remove name=status [file=Note]

Bases (Bases plugin)

Bases(Bases 插件)

bash
obsidian bases
obsidian base:views [file=base.base]
obsidian base:query [file=base.base] [view=name] [format=json|csv|tsv|md|paths]
obsidian base:create name="Item" content="..." [open] [newtab]
bash
obsidian bases
obsidian base:views [file=base.base]
obsidian base:query [file=base.base] [view=name] [format=json|csv|tsv|md|paths]
obsidian base:create name="Item" content="..." [open] [newtab]

Developer commands

开发者命令

Reload a plugin after code changes — essential for the develop/test cycle:
bash
obsidian plugin:reload id=my-plugin
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path=screenshot.png
obsidian dev:dom selector=".cm-editor" [text] [attr=class]
obsidian dev:css selector=".cm-editor" [prop=color]
obsidian dev:console [clear] [limit=10] [level=log|warn|error]
obsidian dev:errors [clear]
代码变更后重新加载插件——这是开发/测试循环的关键步骤:
bash
obsidian plugin:reload id=my-plugin
obsidian eval code="app.vault.getFiles().length"
obsidian dev:screenshot path=screenshot.png
obsidian dev:dom selector=".cm-editor" [text] [attr=class]
obsidian dev:css selector=".cm-editor" [prop=color]
obsidian dev:console [clear] [limit=10] [level=log|warn|error]
obsidian dev:errors [clear]

Quick reference

快速参考

TaskCommand
List commands
obsidian help
Open daily note
obsidian daily
Append to daily
obsidian daily:append content="- [ ] Task"
Search vault
obsidian search query="text"
Read active/specified file
obsidian read
or
obsidian read file=Note
Create from template
obsidian create name="Title" template=Name
List tags with counts
obsidian tags counts
List tasks from daily
obsidian tasks daily
Find broken wikilinks
obsidian unresolved counts
Find orphan notes
obsidian orphans
任务命令
列出所有命令
obsidian help
打开每日笔记
obsidian daily
追加内容到每日笔记
obsidian daily:append content="- [ ] Task"
搜索整个库
obsidian search query="text"
读取活动/指定文件
obsidian read
obsidian read file=Note
从模板创建笔记
obsidian create name="Title" template=Name
带计数列出所有标签
obsidian tags counts
列出每日笔记中的任务
obsidian tasks daily
查找失效的维基链接
obsidian unresolved counts
查找孤立笔记
obsidian orphans

References

参考资料

  • obsidian help
    — full command list (always up to date)
  • obsidian help <command>
    — help for a specific command
  • Obsidian CLI docs (Obsidian)
  • obsidian help
    —— 完整命令列表(实时更新)
  • obsidian help <command>
    —— 特定命令的帮助文档
  • Obsidian CLI 官方文档