macstories / obsidian-shortcut-launcher

Trigger shortcuts in Apple's Shortcuts app from Obsidian with custom commands.
MIT License
187 stars 10 forks source link

Obsidian Shortcut Launcher

Trigger shortcuts in Apple's Shortcuts app as custom commands from Obsidian.

Obsidian Shortcut Launcher (abbreviated as 'OSL') lets you trigger shortcuts and pass along values from Obsidian as input. On iOS and iPadOS, shortcuts are triggered from Obsidian using Apple's official URL scheme for Shortcuts; on macOS, OSL can run shortcuts in the background – without opening the Shortcuts app.

The plugin requires iOS 15, iPadOS 15, or macOS Monterey.

Installing Obsidian Shortcut Launcher

You can find the plugin in Obsidian's Community Plugins section. Just search for 'Obsidian Shortcut Launcher', install it, then enable the plugin to start using it in Obsidian.

Creating Launchers for Shortcuts

Creating launchers for Shortcuts in Obsidian.

OSL works by creating "launchers" for shortcuts you want to run in the Shortcuts app. These launchers show up as individual commands in Obsidian.

You can create a new launcher for Shortcuts in OSL's settings by tapping the 'New' button. When creating a new launcher, there are three main fields you have to configure:

Passing Input Values from Obsidian

Obsidian Shortcut Launcher lets you run shortcuts with input text sent by Obsidian. There are seven different input types you can pass from Obsidian to Shortcuts:

Here is an example of an Obsidian command that has passed the name of the current document to a shortcut in the Shortcuts app:

And here is how you can receive attachments from Obsidian and decode them using base64 in Shortcuts:

Passing Multiple Values with Custom Separators

OSL also features a 'Multiple' option that lets you pass multiple values at once to a shortcut. When you select this option, you can choose multiple input types, which will be passed to Shortcuts all at once with a separator.

By default, the separator character is , (a comma), but you can change it to be whatever you want. To access multiple input values in Shortcuts, use the 'Split Text' action and enter a value for the Custom Separator.

Running Shortcuts with Input from Obsidian

Text passed by OSL to a shortcut is available in the default 'Shortcut Input' variable of the Shortcuts app. In the case of files passed as base64-encoded text, you will have to decode the input first using the dedicated 'Decode Base64' action in Shortcuts.

Due to system limitations, on iOS and iPadOS 15 OSL needs to leave Obsidian and open the Shortcuts app to run a shortcut. That's because shortcuts can only be invoked by other apps with a URL scheme on iOS and iPadOS 15.

On macOS Monterey, OSL can run shortcuts in the background – without opening the Shortcuts app at all – thanks to shell commands. When using OSL on a Mac, you can trigger shortcuts as commands without leaving Obsidian – a powerful experience that perfectly complements the app.