下载地址
https://api.skillhub.cn/api/v1/download?slug=%40user_46180358%2Fobsidian-cli将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @user_46180358/obsidian-cli。Official Obsidian CLI (v1.12+). Complete command-line interface for Obsidian notes, tasks, search, tags, properties, links, and more.
阅读全文 (展开查看完整说明)
概述
Obsidian CLI
Official command-line interface for Obsidian (v1.12+)
The CLI binary file is
obsidian-cliinside the app, but it registers and is invoked asobsidian. The Setup section below covers both ways.
Prerequisites
- Obsidian 1.12+ (1.12.7+ recommended)
- Obsidian app must be running when using CLI commands
- Enable CLI: Settings → General → Command line interface → Toggle ON
Setup
When you toggle the CLI on in Settings → General, Obsidian registers the CLI for your platform. Restart your terminal after enabling.
macOS
Registration creates a symlink at /usr/local/bin/obsidian → /Applications/Obsidian.app/Contents/MacOS/obsidian-cli. Requires admin privileges.
Verify the symlink:
ls -l /usr/local/bin/obsidianIf missing, create it manually:
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian⚠️ Pitfall: The CLI binary changes between Obsidian versions. After updating Obsidian, the existing symlink may break or point to a stale binary. Two ways to fix:
- Re-create the symlink manually (fastest):
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian
- Toggle CLI off → on in Settings → General to let Obsidian re-register.
A simple post-update alias to put in
~/.zshrc:alias obsidian-refresh='sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian'
Alternative without a symlink — add the MacOS dir to PATH and call the binary directly:
export PATH="$PATH:/Applications/Obsidian.app/Contents/MacOS"
obsidian-cli version # works without /usr/local/bin symlinkCleanup: older versions added # Added by Obsidian lines to ~/.zprofile. Safe to delete after re-registering with the current version.
Linux
Binary copied to ~/.local/bin/obsidian. Make sure ~/.local/bin is in your PATH:
export PATH="$PATH:$HOME/.local/bin"Verify:
ls -l ~/.local/bin/obsidianIf missing, copy it manually:
cp /path/to/Obsidian/obsidian-cli ~/.local/bin/obsidian
chmod 755 ~/.local/bin/obsidianWindows
Registration creates Obsidian.com (a terminal redirector for stdin/stdout) in the install folder and adds it to your PATH. Restart your terminal for PATH changes to take effect.
Verify:
Test-Path "$env:LOCALAPPDATAObsidianObsidian.com"Test
obsidian versionSyntax
- Top-level option:
vault=<name>must come first (e.g.obsidian vault="My Vault" daily) - Parameters:
name=valueorname="value with spaces" - Flags: bare name, e.g.
overwrite,newtab,inline,permanent,case - Newlines / tabs: use
nandtinside content strings - Target file:
file=<name>— wikilink-style (resolves by basename, no.md)path=<folder/note.md>— exact path
- Default to active file: most commands default to the active file when
file/pathis omitted - Output formats: many list commands accept
format=text|json|tsv|csv|md|paths(default varies; checkobsidian-cli help <cmd>)
Common Commands (with examples)
Daily Notes
obsidian daily # Open today's daily note
obsidian daily:append content="- [ ] Buy milk" # Add to today's note
obsidian daily:prepend content="# Important" # Add to top of today's note
obsidian daily:read # Print today's content
obsidian daily:path # Print today's file pathFiles
obsidian create name="Note" content="# Hello" # Create a note
obsidian create name="Note" template=Meeting # Create from a template
obsidian read file="Note" # Read note contents
obsidian append file="Note" content="More text" # Append to note
obsidian prepend file="Note" content="Top text" # Prepend to note
obsidian move file="Note" to="Archive/Note.md" # Move note
obsidian rename file="Note" name="New Name" # Rename note
obsidian delete file="Note" permanent # Delete (skip trash)
obsidian open file="Note" newtab # Open note in new tabSearch
obsidian search query="meeting notes" # List matching files
obsidian search:context query="TODO" # Show matching lines
obsidian search:open query="project" # Open search viewTasks
obsidian tasks daily todo # Incomplete tasks in daily note
obsidian tasks todo # All incomplete tasks
obsidian task daily line=3 toggle # Toggle task at line 3
obsidian task ref="Note.md:5" done # Mark a specific task doneTags & Properties
obsidian tags counts # List tags with counts
obsidian tags counts sort=count # Sort by frequency
obsidian tag name="#status" verbose # Files containing a tag
obsidian property:set name="status" value="done" file="Note"
obsidian property:read name="status" file="Note"
obsidian property:remove name="status" file="Note"
obsidian properties file="Note" # List all propertiesLinks
obsidian backlinks file="Note" # Incoming links
obsidian links file="Note" # Outgoing links
obsidian orphans # Files with no incoming links
obsidian deadends # Files with no outgoing links
obsidian unresolved # Broken linksDeveloper
obsidian devtools # Toggle Electron dev tools
obsidian eval code="app.vault.getFiles().length" # Run JavaScript in app context
obsidian dev:screenshot path=screenshot.png # Take a screenshot
obsidian dev:console limit=20 level=error # Show captured console messages
obsidian dev:errors # Show captured errors
obsidian dev:dom selector=".workspace" # Query DOM
obsidian dev:css selector=".mod-header" # Inspect CSS source
obsidian dev:cdp method="Page.reload" # Run a CDP command
obsidian plugin:reload id=my-plugin # Reload a pluginAll Commands (95 total)
Verified against
obsidian-cli helpoutput. Plugin-specific commands (Sync, Publish, etc.) only appear when those plugins are enabled — runobsidian-cli helpagain after enabling a plugin to see its commands.
General (4)
help– Show help / help for a specific commandversion– Show Obsidian versionreload– Reload the vaultrestart– Restart the app
Daily Notes (5)
daily– Open daily notedaily:path– Get daily note pathdaily:read– Read daily note contentsdaily:append– Append content to daily notedaily:prepend– Prepend content to daily note
Files & Folders (12)
file– Show file infofiles– List files in vaultfolder– Show folder infofolders– List folders in vaultopen– Open a filecreate– Create a new fileread– Read file contentsappend– Append content to a fileprepend– Prepend content to a filemove– Move or rename a filerename– Rename a filedelete– Delete a file
Search (3)
search– Search vault for textsearch:context– Search with matching line contextsearch:open– Open search view
Tasks (2)
tasks– List tasks in the vaulttask– Show or update a task
Tags (2)
tags– List tags in the vaulttag– Get tag info
Properties (4)
properties– List properties in the vaultproperty:set– Set a property on a fileproperty:remove– Remove a property from a fileproperty:read– Read a property value
Aliases (1)
aliases– List aliases in the vault
Links (5)
backlinks– List backlinks to a filelinks– List outgoing links from a fileunresolved– List unresolved linksorphans– Files with no incoming linksdeadends– Files with no outgoing links
Outline (1)
outline– Show headings for a file
Bookmarks (2)
bookmarks– List bookmarksbookmark– Add a bookmark
Bases / Database (4)
bases– List all base filesbase:views– List views in a basebase:create– Create a new item in a basebase:query– Query a base and return results
Templates (3)
templates– List templatestemplate:read– Read template contenttemplate:insert– Insert template into active file
Commands & Hotkeys (4)
commands– List available command IDscommand– Execute an Obsidian command by IDhotkeys– List hotkeyshotkey– Get hotkey for a command
Tabs & Workspace (3)
tabs– List open tabstab:open– Open a new tabworkspace– Show workspace tree
File History & Diff (6)
diff– List or diff local/sync versionshistory– List file history versionshistory:list– List files with historyhistory:read– Read a file history versionhistory:restore– Restore a file history versionhistory:open– Open file recovery
Recents (1)
recents– List recently opened files
Word Count (1)
wordcount– Count words and characters
Random Notes (2)
random– Open a random noterandom:read– Read a random note
Vault (2)
vault– Show vault infovaults– List known vaults
Themes & Snippets (9)
themes– List installed themestheme– Show active theme or get infotheme:set– Set active themetheme:install– Install a community themetheme:uninstall– Uninstall a themesnippets– List installed CSS snippetssnippets:enabled– List enabled CSS snippetssnippet:enable– Enable a CSS snippetsnippet:disable– Disable a CSS snippet
Plugins (9)
plugins– List installed pluginsplugins:enabled– List enabled pluginsplugins:restrict– Toggle or check restricted modeplugin– Get plugin infoplugin:enable– Enable a pluginplugin:disable– Disable a pluginplugin:install– Install a community pluginplugin:uninstall– Uninstall a community pluginplugin:reload– Reload a plugin
Developer (10)
devtools– Toggle Electron dev toolseval– Execute JavaScript and return resultdev:screenshot– Take a screenshotdev:console– Show captured console messagesdev:errors– Show captured errorsdev:css– Inspect CSS with source locationsdev:dom– Query DOM elementsdev:cdp– Run a Chrome DevTools Protocol commanddev:debug– Attach/detach Chrome DevTools Protocol debuggerdev:mobile– Toggle mobile emulation
Troubleshooting
"Cannot connect to Obsidian"
- Ensure Obsidian is running
- Enable CLI in Settings → General → Command line interface
"Command not found: obsidian"
- Follow Setup above for your platform
- Verify the symlink:
- macOS:
ls -l /usr/local/bin/obsidian - Linux:
ls -l ~/.local/bin/obsidian
- macOS:
Commands broke right after an Obsidian update
- The CLI binary changes between releases — re-create the symlink:
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidianOr toggle CLI off → on in Settings → General to let Obsidian re-register.
"File not found"
file=Nameresolves like wikilinks (no path, no.md)path=folder/file.mdfor exact paths
中文说明
前置条件
- Obsidian 1.12+(1.12.7+ 推荐)
- Obsidian 必须运行中
- 启用 CLI:设置 → 通用 → 命令行界面
平台配置
macOS:CLI 注册会在 /usr/local/bin/obsidian 创建一个软链接指向 /Applications/Obsidian.app/Contents/MacOS/obsidian-cli。
⚠️ 坑点:升级 Obsidian 后软链接会失效。 二进制文件每次版本更新都会变。最快的修复:
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian或者到 Settings → General 把 CLI 关掉再打开让 Obsidian 重新注册。
Windows:注册会把 Obsidian.com(终端重定向器)放到安装目录并加入 PATH,需要重启终端才生效。
Linux:二进制复制到 ~/.local/bin/obsidian,确保该目录在 PATH 中。
常用命令
obsidian daily # 打开今日日记
obsidian create name="笔记" # 创建笔记
obsidian search query="关键词" # 搜索,只显示文件名
obsidian search:context query="关键词" # 搜索,显示文件名以及内容所在的行
obsidian tasks daily todo # 列出未完成任务
obsidian tags counts # 列出标签