First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
I am trying to run Obsidian CLI commands from the “Run Shell Script” action of a Shortcut, in Mac OS.
Things I have tried
I have created a shortcut with a single action, a “Run Shell Script” block, with the contents:
I run the script, and a second instance of Obsidian launches. The second instance of Obsidian is not logged in to my Sync account, and does not know about my local vault. The result is that the CLI command does not successfully run.
What is your shortcut supposed to do, more precisely ?
I mean, the /Applications/Obsidian.app/Contents/MacOS/obsidian is how you would launch Obsidian (GUI) from the Terminal … but as Obsidian (GUI) needs to be open (before hand) for the CLI to work, it shouldn’t be needed (or potentially written differently, I guess )
Something like this (targeting the currently focused/active vault in Obsidian (GUI)) works fine for me though :
Thanks for the reply, @Pch. The specifics of what the shortcut will do are secondary to the fact that I can’t get the obsidian command to be recognized by Shortcuts in the way you show above. If I enter obsidian vault as a command in the “Run Shell Script” action, I get this error:
```
/Users/foo/Library/Group Containers/group.com.apple.shortcuts/Temporary/com.apple.WorkflowKit.BackgroundShortcutRunner/9EB03BB7-C4E1-4396-9999-267EAC887900:1: command not found: obsidian
```
I have quite a bit of shell customization set up on my machine, but it’s just zsh. Any idea what could interfere?
I’m not a big Shortcuts app user (nor a CLI one for that matter) but it could be helpful to mention what’s your version of Obsidian (the app and the installer version) ?
I’m just asking because there was a change on how Obsidian CLI works (and is registered on path) between the release of Obsidian 1.12.4 and Obsidian 1.12.7 .
With 1.12.7: the CLI got its dedicated binary/executable which was added to PATH through a symlink (as opposed to relying on a profile/rc file for the registration).
So, I’m just wondering if the current version of your Obsidian installer couldn’t play a role in all this …
That said though, with Obsidian 1.12.4 (installer) and the CLI registered on PATH through my .zprofile, I remember having to source the .zprofile first in the “Run Shell Script” action before anything else, otherwise I would run into issue (I sadly do not remember the error message I got at that time so I don’t know if it’s the same as yours).
I also sadly don’t remember (one more time ) why I ended up to using source and/or what made me think it could possibly help at that time … but it did .
With Obsidian 1.12.7 (installer) the source isn’t needed anymore though, as long as Obsidian (GUI) is up and running, like it was already the case with Obsidian 1.12.4 (at least, from what I’ve seen ).