A couple Obsidian CLI wrappers I'm already using
Warning: This one is very “off the dome”. I’m just dumping some quick examples and pushing publish. 😅 I do usually like to explain more as I go, but I wanted to share this before I got too far from thinking about it.
Obsidian CLI finally released for everyone on February 27th! I’ve been waiting for this!
Out of the gate, I needed some things that the CLI doesn’t seem to offer. Eek!
My use cases: I want to write some automations based on my Daily Notes. So I need some arbitrary access to things like “the last weeks worth of daily notes”.
Here’s some things I needed, that I did not find available:
- The path to where
daily-notes(core plugin) stores notes, assuming it’s enabled. - Access to plugin settings values (where I could access that, and naming format settings, etc).
- Any kind of sorting on files output, beyond folder name and file extension.
Things that do exist – related directly to what I wanted – at time of writing:
fileswill list files, in a given folder; filterable by file extension.daily:path(docs) will give you the relative-to-current-vault filename of the “current” daily note file, even if it does not yet exist. E.g.,daily-notes/2026-03-01.md, if you’ve configured the folder and naming convention to such a thing.vault info=pathwill get the path to the current Vault.
Since I wanted to automate some operations on files in my Daily Notes, I needed to mash some things together.
Caveat! I’m not completely at home doing shell scripting.
I am comfortable enough. But also I know there are endless ways to accomplish these sorts of things, and putting this online nearly guarantees someone will point out better ways.
Here’s what I’ve got so far…
Path to Daily Notes directory
This function finds the absolute path the currently configured Daily Notes directory. The directory in which the Daily Notes files are created/stored.
obsidian-daily-notes-path() {
local vault="$(obsidian vault info=path)"
local daily_dir="$(dirname "$(obsidian daily:path)")"
echo "$vault/$daily_dir"
}
Paths to the 7 most recent Daily Notes files
Uses the function above to get the directory, and then some basic file listing to get the “most recent” 7 files.
obsidian-last-7-daily-notes() {
local daily_notes_path
daily_notes_path="$(obsidian-daily-notes-path)"
ls -1r "$daily_notes_path"/*.md 2>/dev/null | head -n 7
}
I am still unsettled if I wanted to use the -t argument for ls, or
just let it sort by name. My filename format is consistently sortable by
date (alpha in the filename). So far, so good.
It also comes to my attention that I should probably use find and some other tools for sorting, instad of ls. It “works on my machine”, so 😅
🤷♂️
I will be expanding this soon to be more generic and take options. E.g., how many days to fetch.
Last 7 Daily Notes content, ready to send in an LLM prompt
I’ve been spending more time directly in “agents” lately, but I’m still a fan
of Simon Willison’s files-to-prompt.
This one mashes the above tools together, and uses files-to-prompt to wrap the
content of a week of Daily Notes into a single, prompt-ready payload.
(I’ve heard the recent models don’t care as much about the XML formatting. But it’s still working great for me).
obsidian-last-7-daily-notes-to-prompt() {
obsidian-last-7-daily-notes | tr '\n' '\0' | xargs -0 files-to-prompt --cxml
}