A small CLI for reading and writing notes in a local Obsidian vault.
Project description
odcli
odcli is a local Python CLI for reading and writing notes in an Obsidian vault.
It works directly on Markdown files inside the vault, so it does not depend on private Obsidian APIs and remains portable and easy to extend.
Features
- Validate whether a vault path is available
- List Markdown notes in the vault
- Read a specific note
- Read a specific line range from a note
- Overwrite a note or create it automatically
- Replace a specific line range in a note
- Append content to a note
- Full-text search across the vault
- Auto-discover the default vault from Obsidian config or common macOS and Windows locations
Using uv
cd /Users/huchang/agents/obsidian_cli
uv sync
uv run odcli --help
Run tests:
cd /Users/huchang/agents/obsidian_cli
uv run python -m unittest discover -s tests
Build distributions:
cd /Users/huchang/agents/obsidian_cli
uv build
The published package name on PyPI is odcli.
After installation, both odcli and obsidian-cli are available as command names.
Run Locally
cd /Users/huchang/agents/obsidian_cli
./odcli --help
The compatibility entry point is still available:
cd /Users/huchang/agents/obsidian_cli
./obsidian-cli --help
If you prefer module execution:
PYTHONPATH=src python3 -m obsidian_cli --help
Vault Resolution
Resolution priority:
--vault /path/to/vaultOBSIDIAN_VAULT- The most recently opened vault recorded by local Obsidian config
- Common default directories
Built-in default locations:
- macOS:
~/Documents/Obsidian Vault - macOS:
~/Documents/Obsidian - macOS iCloud:
~/Library/Mobile Documents/iCloud~md~obsidian/Documents - Windows:
%USERPROFILE%\\Documents\\Obsidian Vault - Windows:
%USERPROFILE%\\Documents\\Obsidian
Example:
export OBSIDIAN_VAULT="/Users/your-name/Documents/MyVault"
./odcli check
./odcli list
./odcli read Inbox/today.md
./odcli read-lines Inbox/today.md 3 8
./odcli write Inbox/today.md --content "# Today"
./odcli write-lines Inbox/today.md 3 4 --content "- replaced\n- lines\n"
./odcli append Inbox/today.md --content "\n- new item"
./odcli search "project alpha"
Commands
check
Validate that the vault exists and report whether .obsidian is present.
list
List Markdown notes in the vault.
Optional arguments:
--limit N
read
Read a note.
Arguments:
note_path: path relative to the vault root
write
Overwrite a note. Parent directories are created automatically if needed.
Arguments:
note_path--content TEXT--stdin
Optional arguments:
--create-only
read-lines
Read a line range. Line numbers are 1-based and inclusive.
Arguments:
note_pathstart_lineend_line
write-lines
Replace a line range. Line numbers are 1-based and inclusive.
Arguments:
note_pathstart_lineend_line--content TEXT--stdin
append
Append content to the end of a note.
Arguments:
note_path--content TEXT--stdin
search
Search across all Markdown notes in the vault.
Arguments:
query--case-sensitive
Testing
cd /Users/huchang/agents/obsidian_cli
uv run python -m unittest discover -s tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odcli-0.1.3.tar.gz.
File metadata
- Download URL: odcli-0.1.3.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04a9e48e4c926f5c697c0ddaf8ca37c789d7cf6a10fc6d3c6273ab445acc1e55
|
|
| MD5 |
73d1a838feeb75ea56434fc1b7388151
|
|
| BLAKE2b-256 |
fe560baacdb30744813375e7797d39a0e98ecdb9490f77b8183b056555e2077d
|
File details
Details for the file odcli-0.1.3-py3-none-any.whl.
File metadata
- Download URL: odcli-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf0e07e6a83ae7d7627fe95c83629d0b7499e02f6807fa216d18a94453222fa
|
|
| MD5 |
fcdb5c0fb4ba7ac4d0103c2b10bf2b6f
|
|
| BLAKE2b-256 |
b9fc3544c943acdc657aba43856960efed9f3e1fc48899cfadcb0ba76f8e9b62
|