Alfred Workflow - Bypass for Shortcuts

This workflow has been enhanced and full documentation can be found on the Alfred Workflow - Bypass for Shortcuts page.

I recently updated my Macbook Pro to macOS Monterey, and with it I got access to running Shortcuts on the Mac. Being a long time power user of Shortcuts, all the way back to the first release of Workflow, it was quite exciting to get my hands on the app. I’ve been enjoying experimenting with it, but I decided I needed to improve the accessibility. Enter one of my favourite Mac apps, Alfred.

What is Shortcuts?

Shortcuts is a no-code application that has been available on i*OS devices for several years and allows users to build up procedural automations. They tend to be quite linear unless you work a little to create recursive shortcuts (a shortcut being the equivalent of an execution script) or utilise libraries of scripts. As a no-code solution it is highly visual, and being able to now build Shortcuts on the Mac, the extra screen estate that is available for this is something I really appreciate.

Shortcuts ties in at the OS level and has support built-in to many third party applications (on i*OS). This makes it an app that is very useful, and usable. It was seen as a spiritual successor to Automator, and with the mac release and feature parity with Automator, it seems that Automator has now reached the twilight years.

Triggering Shortcuts

Shortcuts can be set up to be available in the menu bar, the share sheet, and as services. Services can also be assigned keyboard shortcuts. That’s a pretty good range of ways to access them.

But oddly, I could not see a way to trigger them from Spotlight. There seems to be no option to enable them to show up in search.

Similarly, there was no option in my preferred launcher, Alfred.

But hey, it’s Alfred. Alfred is quite versatile and I have built several Alfred workflows before to do this sort of thing with other applications. I figured, why not do it for Shortcuts too? So I had a noodle about with things for a few hours until I came up with something that seemed to fit the gap.

Workflow: Bypass

Welcome to my latest Alfred workflow, “Bypass”. It is predominantly a simple launcher for Shortcuts’ shortcuts on the Mac. But, it includes a few other useful bits and pieces too. The collection of flows in the Alfred workflow look like this:

Download Bypass

Prerequisite: macOS Monterey or higher - the first macOS with support for Shortcuts.

For more Alfred workflows, take a look at the downloadable workflow list on the Alfred project page.

About Bypass

The following description is included in the Workflow, and outlines the functionality it provides.

Bypass is an Alfred workflow for working with Apple’s Shortcuts app. Its primary purpose is to allow you to launch your Shortcuts workflows (known as shortcuts) from Alfred, potentially even passing in content to be processed. Bypass contains a number of keyword, external trigger and universal action triggers to enable this.

Keyword Triggers

scrun
Allows you to select a shortcut from all available shortcuts and run it. The shortcut does not receive any input.

Holding down the Alt/Option key will switch the action to allow a Shortcuts folder to be selected prior to the selection of the shortcut to run, and will filter the list of available shortcut names accordingly.

scruni
Allows you to select a shortcut from all available shortcuts, capture some text input, and run the shortcut with the text as input to be processed by the shortcut.

Holding down the Alt/Option key will switch the action to allow a Shortcuts folder to be selected prior to the selection of the shortcut to run, and will filter the list of available shortcut names accordingly.

scrunf
Allows you to select a shortcut folder from all available Shortcuts folders, then select a shortcut from within that folder and run it. The shortcut does not receive any input.

scrunfi
Allows you to select a shortcut folder from all available Shortcuts folders, then select a shortcut from within that folder, then capture some text input, and run the shortcut with the text as input to be processed by the shortcut.

scedit
Allows you to select a shortcut from all available shortcuts and open it for editing.

Holding down the Alt/Option key will switch the action to allow a Shortcuts folder to be selected prior to the selection of the shortcut to edit, and will filter the list of available shortcut names accordingly.

sceditf
Allows you to select a shortcut folder from all available Shortcuts folders, then select a shortcut from within that folder and open it for editing.

sccopy
Copies an alphabetically sorted list of all shortcut names to the system clipboard.

scfcopy
Copies an alphabetically sorted list of all Shortcuts folder names to the system clipboard.

scinfo
Copies a set of Shortcuts information to the system clipboard. This includes alphabetical listings of folders, shortcuts within folders, shortcuts not in folders, and counts of shortcuts within folders, no-folders and total.

Universal Action Triggers

Send to a shortcut
Sends selected text or URL to a shortcut as input to be processed. A shortcut is selected from all available shortcuts, and the content is passed to the shortcut as input to be processed.

Holding down the Alt/Option key will switch the action to allow a Shortcuts folder to be selected prior to the selection of the shortcut to run, and will filter the list of available shortcut names accordingly.

Send file to a shortcut
Sends selected file to a shortcut as input to be processed. A shortcut is selected from all available shortcuts, and the content is passed to the shortcut as input to be processed.

Holding down the Alt/Option key will switch the action to allow a Shortcuts folder to be selected prior to the selection of the shortcut to run, and will filter the list of available shortcut names accordingly.

External Triggers

scrun
Allows you to specify a shortcut by name (passed in as the “{query}”), and run it. The shortcut does not receive any input.

scruni
Allows you to specify a shortcut by name, capture some text input, and run the shortcut with the text as input to be processed by the shortcut. The shortcut name should be specified in the “shortcut2run” variable, and the text to process > passed in as the “{query}”.

scedit. Allows you to specify a shortcut by name (passed in as the “{query}”) and open it for editing.

sccopy. Copies an alphabetically sorted list of all shortcut names to the system clipboard.

scfcopy
Copies an alphabetically sorted list of all Shortcuts folder names to the system clipboard.

scinfo. Copies a set of Shortcuts information to the system clipboard. This includes alphabetical listings of folders, shortcuts within folders, shortcuts not in folders, and counts of shortcuts within folders, no-folders and total.

Creating Bypass

This Alfred workflow is all built around the command line interface to Shortcuts. Yes, you can in fact interact with Shortcuts at the command line. Open your terminal, type in man shortcuts, and you will get the idea. Everything in the workflow is based around triggering actions or retrieving data using the shortcuts utility. As a result, most of the more technical elements of the workflow are one line shell commands. There is a more complexity in the scripts to retrieve folder and shortcut listings, and the information summary (scinfo) also has bit of work in it in order to get the shortcuts not in any folder and the count right for folders with no shortcuts in them.

Conclusion

It may only be a matter of time before launching shortcuts from Spotlight or Alfred has something native in place, but I think even if that does happen, there is probably some value in keeping this workflow around. I strongly suspect it won’t give you the copy options, the folder options, the input options, or the equivalents of the Universal Actions. Whatever happens in the future, this gives me quick and easy access to my Shortcuts from my preferred launcher utility, and that’s a big benefit to me today. As usual, I’m sharing this on in the hope that you will find it useful too.

Do let me know if you find it useful, and of course if you note any buggy behaviour.

Author: Stephen Millard
Tags: | shortcuts | alfred |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read