A CLI would help to interact with Obsidian from the terminal and integrate with existing processes and tools.
Here are a few commands I wish that existed in this command line interface for Obsidian:
obs folder opens a folder as vault
obs file.md opens a specific file directly
obs starred, obs daily, obs random for a direct access to these notes in your default vault
Mod-Edit:
Many actions are already available using Obisidian-URI which can be called from the command line.
Some of these functions are complicated by the fact that obsidian needs to know which vault the file you are targeting belongs to. Obsidian fundamentally manages your vault(s) not single files.
I think you mean a way to open Obsidian from the command line, but if you’re looking for a tool to just access notes, I use a program called Terminal Velocity 3 (https://github.com/aramiscd/tv3) . It has a filename search that lets you just start typing, and it filters matching results.
By default, it uses .txt formatting, but if you configure a .tvrc file in your home directory, you can set it up to use .md and the same root folder as Obsidian (I use a Dropbox synced folder):
[DEFAULT]
# The filename extension to use for new files.
extension = .md
# The filename extensions to recognize in the notes dir.
extensions = .txt, .md, .markdown, .rst
notes_dir = ~/Dropbox/notes
This setup covers about 80% of what I would need from a command line tool, since I usually just can use the UI.
Terminal Velocity 3 looks like a great tool to open files, this requested feature however is about controlling Obsidian from the CLI to use its features such as Create Zettelkasten note, Get random note or linking between notes in a visual way.
This would be a helpful addition. I have a few customers of imdone.io who would like to open obsidian from cards on their imdone kanban board. Specifically I’d like to have a way to open a file to a specific line.
+1 for this especially. It would be helpful to integrate with Keypirinha which is a keyboard driven application launcher, like the old Launchy or Find and Run Robot. Keypirinha is the first thing I install on a new PC.
This feature is key to integrate Obsidian with all kinds of automated flows, and have it as an option for replacing current note editors.
Two notes:
Being able to use the existing instance of the app is the key to make this useful. In some editors this is a configurable behavior that’s enabled by default.
A nice bonus would be to optionally specify a line to jump to, i.e. obsidian file.md +155 would open file.md at line 155 (this is the syntax gedit uses).
For example, obsidian file.md +155 can have the following behaviors:
If there’s no open instance of Obsidian, launch the app and open file.md when the cursor is at line 155.
If there’s an open instance of Obsidian and this file is open, jump to where this file is open and go to line 155.
If there’s an open instance of Obsidian and the file is not open, open it and go to that line.
For me, I would like to use some keyboard bindings to open certain vaults, which uses terminal command line to launch those obsidian with the select vaults. I have multiple vaults: Zettelkasten, Notes, and Journal. It would really nice to have this feature implemented as it will reduce the redundant work of selecting the right vault manually from the UI. Thanks!
I was imagining having indexes living in excel spreadsheets. Use python scripts and/or manual work to generate spreadsheets with custom columns, formatting, and hyperlinks which go to specific markdown files. Click on hyperlink, opens with default app for .md filetype, opens in current Obsidian instance.
Alright, here’s a hack that would work:
create a wrapper script/executable to use as command line opener for obsidian
(optional) associate the script/executable with OS default app for .md files
assume the script takes the desired file to open as an argument
have the script killall obsidian instances (could be more sophisticated…)
have the script edit $vault/.OBSIDIAN/workspace and set "file": "the_file.md" under “main” (most obvious for this POC anyway; and maybe another cmdline argument could be path to $vault so it only kills and modifies that one vault)
have the script restart obsidian
Hopefully the whole thing takes no more than a second.
I tried manually doing this without writing a wrapper. Tried skipping step 4, or not killing obsidian, but the UI didn’t update simply after saving changes to the workspace file. Restarting obsidian was required
Personally, this would make it much easier for me to customize how I navigate my computer. (Windows user.) I use autohotkey, so this would let me whip up an interface to go to any file on my computer that I want to edit, in the app I want to use for editing it:
VS Code for code
Obsidian for notes
[undetermined] for doodles and drawings
A DAW for music
etc.
This would make Obsidian more integrated with the whole flow of using my computer, making it an element of the whole software instead of its own isolated/siloed app.
This provides a command line interface, via the terminal open command.
For example, I have custom QMK Firmware on my keyboard, giving me a keystroke that triggers an Alfred workflow to open today’s scratch file in Obsidian. The relevant code is a Bash script:
proj='/Volumes/All/Global/Log'
obsidian='obsidian://open?vault=Log&file='
path=$( date "+${proj}/%Y/%m/%d" )
file=$( date "+${path}/%d.md")
url=$( date "+${obsidian}%Y%%2F%m%%2F%d%%2F%d")
mkdir -p "${path}"
touch "${file}"
if ! pgrep Obsidian >/dev/null
then
open -a 'Obsidian'
sleep 1
fi
open "${url}"
Obsidian needs to be already open to honor a specific page request, hence the double-clutching in the script.