You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Note**: With the release of the official Obsidian CLI., this project has been renamed from "Obsidian CLI" to "NotesMD CLI" to avoid confusion. NotesMD CLI works **without requiring Obsidian to be running**, making it perfect for scripting, automation, and terminal-only environments.
3
+
> **Note**: With the release of the official Obsidian CLI, this project has been renamed from "Obsidian CLI" to "NotesMD CLI" to avoid confusion. NotesMD CLI works **without requiring Obsidian to be running**, making it perfect for scripting, automation, and terminal-only environments.
4
+
5
+
---
6
+
7
+
## Table of Contents
8
+
9
+
-[Description](#description)
10
+
-[Install](#install)
11
+
-[Windows](#windows)
12
+
-[Mac and Linux](#mac-and-linux)
13
+
-[Arch Linux (AUR)](#arch-linux-aur)
14
+
-[Build from Source](#build-from-source)
15
+
-[Headless / No Obsidian Installed](#headless--no-obsidian-installed)
16
+
-[Migrating from Obsidian CLI](#migrating-from-obsidian-cli)
17
+
-[Usage](#usage)
18
+
-[Help](#help)
19
+
-[Editor Flag](#editor-flag)
20
+
-[Add Vault](#add-vault)
21
+
-[Remove Vault](#remove-vault)
22
+
-[List Vaults](#list-vaults)
23
+
-[Set Default Vault and Open Type](#set-default-vault-and-open-type)
24
+
-[Open Note](#open-note)
25
+
-[Daily Note](#daily-note)
26
+
-[Search Note](#search-note)
27
+
-[Search Note Content](#search-note-content)
28
+
-[List Vault Contents](#list-vault-contents)
29
+
-[Print Note](#print-note)
30
+
-[Create / Update Note](#create--update-note)
31
+
-[Move / Rename Note](#move--rename-note)
32
+
-[Delete Note](#delete-note)
33
+
-[Frontmatter](#frontmatter)
34
+
-[Deprecated Commands](#deprecated-commands)
35
+
-[Excluded Files](#excluded-files)
36
+
-[Contribution](#contribution)
37
+
-[License](#license)
4
38
5
39
---
6
40
@@ -62,12 +96,35 @@ go build -o notesmd-cli .
62
96
sudo install -m 755 notesmd-cli /usr/local/bin/
63
97
```
64
98
65
-
### Headless / No Obsidian Installed
99
+
### Headless / No Obsidian Installed
66
100
67
-
If you're running on a headless server or don't have Obsidian installed (e.g., server environments, containers, or systems without a GUI), you can still use this CLI. Obsidian requires a GUI, so this section explains how to set up the required configuration manually.
101
+
If you're running on a headless server or don't have Obsidian installed (e.g., server environments, containers, or systems without a GUI), you can still use this CLI. When Obsidian is installed, it registers vaults automatically. For headless environments, you register them via the CLI instead.
@@ -83,22 +140,9 @@ If you're running on a headless server or don't have Obsidian installed (e.g., s
83
140
}
84
141
}
85
142
```
86
-
The key (`any-unique-id`) can be anything — the CLI uses the **directory name** as the vault name (e.g., `my-brain` above). Use the **absolute path** — do not use `~` as the CLI does not expand it to your home directory.
143
+
The key (`any-unique-id`) can be anything. The CLI uses the **directory name** as the vault name (e.g., `my-brain` above). Use the **absolute path**. Do not use `~` as the CLI does not expand it to your home directory.
87
144
88
-
**Multiple vaults:**
89
-
```json
90
-
{
91
-
"vaults": {
92
-
"vault-1": {
93
-
"path": "/home/user/vaults/personal"
94
-
},
95
-
"vault-2": {
96
-
"path": "/home/user/vaults/work"
97
-
}
98
-
}
99
-
}
100
-
```
101
-
You can then use `notesmd-cli set-default "personal"` or pass `--vault "work"` to target a specific vault.
To avoid passing `--editor` every time, configure it as the default open type once:
146
190
147
191
```bash
148
-
notesmd-cli set-default --open-type editor
192
+
notesmd-cli set-default-vault --open-type editor
149
193
```
150
194
151
-
### Set Default Vault and Open Type
195
+
### Add Vault
152
196
153
-
Defines the default vault and/or open type for future usage. If no default vault is set, pass `--vault` with other commands to specify which vault to use.
197
+
Registers a directory as an Obsidian vault. Creates the Obsidian config file (`~/.config/obsidian/obsidian.json`) if it does not exist. Alias: `av`
154
198
155
-
```bash
156
-
# Set default vault (vault name only, not the path)
157
-
notesmd-cli set-default "{vault-name}"
199
+
If you have Obsidian installed, vaults are registered automatically when you open them. You only need this command for headless setups or environments where Obsidian is not installed (servers, containers, CI).
158
200
159
-
# Set default open type: 'obsidian' (default) or 'editor'
When `default_open_type` is set to `editor`, commands that support `--open` will open notes in `$EDITOR` automatically, without needing to pass `--editor` each time.
209
+
### Remove Vault
167
210
168
-
Note: `open` and other commands in `notesmd-cli` use this vault's base directory as the working directory, not the current working directory of your terminal.
211
+
Removes a vault from the Obsidian config. Does not delete any files on disk. If the removed vault was the default, the default is cleared. Alias: `rv`
169
212
170
-
### Print Default Vault
213
+
```bash
214
+
# Remove by vault name
215
+
notesmd-cli remove-vault "{vault-name}"
171
216
172
-
Prints default vault and path. Please set this with `set-default` command if not set.
217
+
# Remove by vault path
218
+
notesmd-cli remove-vault /path/to/vault
219
+
```
220
+
221
+
### List Vaults
222
+
223
+
Lists all registered Obsidian vaults. The default vault is marked with `(default)`. Alias: `lv`
173
224
174
225
```bash
175
-
#print the default vault name and path
176
-
notesmd-cli print-default
226
+
#Lists all vaults (name and path, default marked)
227
+
notesmd-cli list-vaults
177
228
178
-
# print only the vault path
179
-
notesmd-cli print-default --path-only
229
+
# Outputs vaults as JSON
230
+
notesmd-cli list-vaults --json
231
+
232
+
# Outputs only vault paths (useful for scripting)
233
+
notesmd-cli list-vaults --path-only
234
+
235
+
# Show only the default vault (name, path, open type)
236
+
notesmd-cli list-vaults --default
237
+
238
+
# Get just the default vault path (useful for scripting)
239
+
notesmd-cli list-vaults --default --path-only
180
240
```
181
241
182
242
You can add this to your shell configuration file (like `~/.zshrc`) to quickly navigate to the default vault:
183
243
184
244
```bash
185
245
obs_cd() {
186
-
local result=$(notesmd-cli print-default --path-only)
246
+
local result=$(notesmd-cli list-vaults --default --path-only)
187
247
[ -n"$result" ] &&cd -- "$result"
188
248
}
189
249
```
190
250
191
251
Then you can use `obs_cd` to navigate to the default vault directory within your terminal.
192
252
193
-
### List Vaults
253
+
### Set Default Vault and Open Type
194
254
195
-
Lists all registered Obsidian vaults. Alias: `lv`
255
+
Defines the default vault and/or open type for future usage. If no default vault is set, pass `--vault` with other commands to specify which vault to use.
196
256
197
257
```bash
198
-
#Lists all vaults (name and path)
199
-
notesmd-cli list-vaults
258
+
#Set default vault (by name or path)
259
+
notesmd-cli set-default-vault "{vault-name}"
200
260
201
-
#Outputs vaults as JSON
202
-
notesmd-cli list-vaults --json
261
+
#Set default open type: 'obsidian' (default) or 'editor'
When `default_open_type` is set to `editor`, commands that support `--open` will open notes in `$EDITOR` automatically, without needing to pass `--editor` each time.
269
+
270
+
Note: `open` and other commands in `notesmd-cli` use this vault's base directory as the working directory, not the current working directory of your terminal.
271
+
208
272
### Open Note
209
273
210
274
Open given note name in Obsidian (or your default editor). Note can also be an absolute path from top level of vault.
@@ -227,7 +291,7 @@ notesmd-cli open "{note-name}" --editor
227
291
228
292
### Daily Note
229
293
230
-
Creates or opens today's daily note directly on disk —**Obsidian does not need to be running**. If `.obsidian/daily-notes.json` exists in the vault, the CLI reads `folder`, `format` (Moment.js date format, default `YYYY-MM-DD`), and `template` from it. A template file's content is used when creating a new daily note. If the config is missing or unreadable, defaults are used (vault root, `YYYY-MM-DD`, no template).
294
+
Creates or opens today's daily note directly on disk.**Obsidian does not need to be running**. If `.obsidian/daily-notes.json` exists in the vault, the CLI reads `folder`, `format` (Moment.js date format, default `YYYY-MM-DD`), and `template` from it. A template file's content is used when creating a new daily note. If the config is missing or unreadable, defaults are used (vault root, `YYYY-MM-DD`, no template).
Creates a note (can also be a path with name) directly on disk —**Obsidian does not need to be running**. If the note already exists and neither `--overwrite` nor `--append` is passed, the file is left unchanged. Intermediate directories are created automatically.
385
+
Creates a note (can also be a path with name) directly on disk.**Obsidian does not need to be running**. If the note already exists and neither `--overwrite` nor `--append` is passed, the file is left unchanged. Intermediate directories are created automatically.
322
386
323
387
When the note name has no explicit path (no `/`), the CLI reads `.obsidian/app.json` from the vault to check for a configured default folder (`newFileLocation: "folder"` and `newFileFolderPath`). If configured, the note is placed in that folder. If the config is missing or unreadable, the note is created at the vault root.
The following commands still work but print a deprecation warning to stderr (so pipes and scripts are unaffected). They will be removed in the next major version.
0 commit comments