Using Alfred && Apple Shortcuts to do Really Cool Things

Alfred is absolutely amazing at doing high level stuff, but actually doing application level tasks is sort of limited to AppleScript, external APIs, and other sort of work arounds. Shortcuts on the other hand, is kind of clunky to do high level stuff, but any respectable third party app will have a ton of hooks and actions for Shortcuts to interact and do things within apps.

Using both these apps together, we’d get the best of both worlds. & after reading this post and Workflow by the Alfred team, it seems there’s actually a super easy way to trigger and interact with Shortcuts from terminal, and thus Alfred:

$ /usr/bin/shortcuts --help

This is a game changer. Here’s a Alfred workflow + Shortcut mash up I did to solve a real problem I was having:

My biggest improvement working day to day was when on Zoom calls I’d sometimes forget an action item I need to follow up on. One could argue I just needed to ensure I have my note taking window open, but that doesn’t work for me as I often am deep in many windows during a call and focused on the call. What I needed and wanted was to smash a global hotkey and be presented with a text prompt, type my string, hit enter, and it’d be stashed somewhere safe (much like Things quick entry, but I don’t use Things.app for work, I keep my Todos in my Note app).

To build this, I created a “@daily quick note” Apple Shortcut which prepends a string of text to add to a note in my note taking app (currently Bear.app) in a note I use everyday.

I tried using Apple Shortcut’s text input prompt, and using their keyboard shortcut listener but:

  1. When hitting return in the Shortcut text prompt, the dialog box doesn’t close, it creates a new line 🤦‍♂️. Tab and other tricks to escape don’t work either, so a mouse move is apparently required. & That’s not gonna fly.
  2. I got inconsistent results from the global keyboard shortcut from Apple Shortcuts, it worked sometimes but not every time – it must be more reliable.

So instead I the Apple Shortcut to accept an incoming argument:

With this Shortcut setup to accept input, I then created an Alfred workflow with a keyword “+” input, where I can add my action item.

This allows me to capture a thought pretty quickly (as I’m always using and very fluent in Alfred), & globally no matter where my note apps window currently is:

After the Alfred “+” keyword input, I’ve got a simple action run script in bash that takes advance of how Apple setup shortcuts:

query=$1

/usr/bin/shortcuts run "@daily quick note" -i <<< "${query}"

So typing + email that person about that thing and hitting enter will run my “@daily quick note” Shortcut, and pass in my string from Alfred, which interacts with my note taking app, and prepends the string to my daily note, capturing my action item that I don’t want to forget for parsing later.

For bonus points, in Alfred I also setup the keyboard shortcut hotkey (which works very reliably compared to Apple Shortcuts) to run “Utilities > Show Alfred” and auto populated the “+” keyword, so I can quickly pop open Alfred with the + keyword there, and enter my string right away. A second saver to help me retire early.

This example is pretty rudimentary, I’m simply changing the user input from the unreliable Shortcuts app to the easier and more familiar Alfred app, which is great, but the bigger take away here is there’s much more potential to do more interesting things with these two apps being able to work together.

Leave a Reply

Your email address will not be published.