Using macOS Shortcuts with an Alfred workflow

When Apple's Shortcuts was released on macOS Monterey, our community started asking for ways to run shortcuts from Alfred. You’re so passionate about automation that you want to automate your automations, and we love that!

So we created a Workflow for running shortcuts, which you can download from Github. You'll also need to download the linked Shortcuts actions below to use them.

To list all your installed shortcuts, open Alfred and type sc.

List shortcuts with sc

If you're hyper-organised, you may have your shortcuts separated in folders. scd reveals those.

List shortcut folders with scd

There are three main ways to run shortcuts:

Just Run it

Newest Short of the Week is as simple as it gets. Run it with ↵ and it opens the latest post on the Short of The Week website. Great when you're looking for something quick to watch on a break.

Choosing Newest Short of the Week shortcut

Newest Short of the Week shortcut layout

Pass Files to it

Upload to Imgur does what it says on the tin: Select one or more images, press your Universal Actions hotkey and run the shortcut to upload your images. You'll get a notification and the links will automatically be copied to your clipboard.

File Action to run shortcuts

Choosing Upload to Imgur shortcut

Upload to Imgur shortcut layout

Give it an Argument

Calm Notifications controls Do Not Disturb. It needs an argument of on, off, or a number (enables Do Not Disturb for that number of minutes).

To give an argument to a shortcut, action it with ⌘↵. Alternatively, select text anywhere and press your Universal Actions hotkey - it works like passing a file.

Choosing Calm Notifications shortcut via sc, with an argument

Giving argument to Calm Notifications shortcut

Calm Notifications shortcut layout

Adding arguments to your shortcuts is a powerful way to integrate them with Workflows. CalmNotifications is also a Workflow which seamlessly runs the above shortcut and uses other Alfred features to give feedback on the current state of Do Not Disturb.

Be sure to check John Voorhees's rundown of the Shortcuts Workflow at MacStories for more examples.

Workflow Tutorial: Using a Single Keyword for Multiple Snippets

Did you know that you can use a single snippet keyword for multiple snippets? Typing your snippet keyword in any app will pop up Alfred with a list of options to choose from, and pressing Return will paste it to the frontmost app.

In this post, I'm using three email signatures as an example; Depending on the situation, I can choose which of my three identities I want to use.

Snippet Triggers options

Trigger Email Signatures with Snippets

If you'd like to follow along, you can download the example workflow on GitHub or you can create your own workflow and add the objects as you go.

Snippet Triggers workflow canvas

1. Using the keyword:

Open the Snippet Trigger object and set your keyword, which you'll type with any prefix or suffix you've set in the Shared Prefix box found in the Snippet Trigger object.

Setting your snippet trigger keyword

Note that in this example, my keyword is \\sig as the Shared Prefix is set to \\.

2. Setting the snippet content:

Change the content of your signatures in the List Filter object to reflect identities that are useful to you.

This can be used for any scenario where you need to paste different content, but want to only have to remember a single snippet trigger.

List filter options

You'll notice that none of the List filter keyword details are filled in, as we won't be accessing the workflow through the list filter keyword in this case. However, you could fill this in and access the workflow from Alfred results too.

3. Pasting the snippet content:

The workflow is currently set to automatically paste to the frontmost app, so no changes are needed in this object.

Note that you'll need to have granted Alfred the necessary Accessibility permissions required for the Snippets feature. Here's a guide to setting up Alfred's Snippets Text Expansion feature if needed.

Open a text file or an email, type your snippet, choose the snippet you want to paste, press Return and like magic, your snippet will appear!

I bet you can think of you a dozen other ways you could use snippets like these now that you've created one.

TinyPNG Workflow: Compress Your Images

TinyPNG panda mascot TinyPNG is a web service that allows you to reduce the size of your images with no perceptible loss in quality, while shrinking the size of your files significantly. It's brilliantly useful, so we've made a workflow for it!

You can compress PNG, JPEG, and WebP images without having to hop over to their website and manually dragging in images, as their API makes it a breeze to use directly from the TinyPNG Alfred workflow.

Whether you're designing a new website, posting to your blog or creating an Alfred workflow, the more optimised the images are, the more lightweight your page or workflow will be. Using TinyPNG can shrink a file size to a tenth its original size, making your exported workflow far more suitable for sharing!

Setting up the TinyPNG Workflow

1. Install the workflow

Download the TinyPNG Alfred Workflow from GitHub and install it by double-clicking the file, which will launch Alfred's preferences and pop up the workflow's Readme and setup window.

2. Get your API key

You'll have to register for an API key and add it as a Workflow Environment Variable.

Because TinyPNG's compression is lossy - meaning information is discarded - the Workflow backs up your originals. By default, they are saved to a temporary directory which is cleaned on every reboot.

As of writing, TinyPNG lets you compress 500 images per month for free.

3. Choose your favourite way to use the workflow

You can access the workflow in a few ways; File Action, File Filter, or External Trigger, take your pick!

To use it as a File Action, select one or more files in Alfred or Finder, and use your Universal Action hotkey (which is ⌘/ by default) to pop up the list of actions. You can then type "tinypng" or choose "TinyPNG Compression" from the actions list.


To use the File Filter, use the keyword "tinypng" in Alfred to choose the workflow, then search for the name of the image you want to optimise.


And finally, you can use an External Trigger to call this action from another workflow or AppleScript.

tell application id "com.runningwithcrayons.Alfred"
    run trigger ¬
        "compress" in workflow ¬
        "com.alfredapp.tinypng" with argument ¬
        (POSIX path of (path to desktop folder)) & "tinypng panda.png"
end tell

Enjoy your efficiency boost!

Searching Google Drive with an Alfred workflow

If you use Google Drive on macOS, chances are Spotlight isn't indexing your File Stream paths. This long-standing limitation is a problem because if Spotlight can't find those files, neither can Alfred.

Or can it?

Alfred uses Spotlight's indexing, so it sees what it sees. By default. With Alfred's Workflows you get greater flexibility of results and powerful combinations: if you'd care to do it, you could even use Workflows to build a mini private Spotlight targeting a specific set of files.

So that's what we did.

The Google Drive Workflow has gradually evolved with the help of our users on the forum. It relies on standard tools to create a database of your Google Drive's local structure without requiring futzing with API keys or complex configurations.

Using the Workflow

After you download and install the Workflow, invoke Alfred and run :gdlaunchd. This will create the initial cache and load a job to redo it every day. The build will take a while, depending on how many files you store in Google Drive.


When it's done, you will see a notification.


And that's it, you're ready to go!

Use gd and gdf to find your files and folders.


gd fran

The Workflow has sane defaults but does allow a degree of customisation. See the instructions for details on the options.

Tutorial: Share your Workflows Using GitHub

GitHub Octocat

The community of Alfred workflow creators spans the world, and the breadth of the Mac ecosystem.

To help new workflow creators share their work, Vítor Galvão, long-time Alfred workflow creator and community member, wrote this guide to sharing your workflows on GitHub.

First, we'll take a look at how to host your workflows on GitHub, which is free, then at the fun part - sharing your workflows with your friends and colleagues.

Part 1: Hosting the Workflow

Typical file hosting services are rife with tradeoffs, usually offering short-lived links. Ideally you'll want to share your Workflow somewhere free of transfer and storage costs, with an established reputation, and that allows you update to your work.

GitHub ticks all the boxes, but it may be daunting to know where to start if you're not a technical person. We'll demystify the process.

  1. Signup for GitHub. You'll set up your email, password, and username.
    • If you're redirected to a "Welcome to GitHub" or similar page where they ask about you or your team, feel free to ignore it.
  2. Create a new repository (the page where your Workflow will live).
    • Set Repository name to something short but descriptive. Example: alfred-search-wikipedia.
    • Under Initialize this repository with, tick the Add a README file box.
  3. You will be redirected to your Workflow's repository page on GitHub. Save the URL in the address bar, it's what you'll share with other people.
  4. Open Alfred Preferences, go to Workflows and locate yours.
  5. Right-click your Workflow in the list and Open in Finder. Copy it to your Desktop.

IMPORTANT: If you're not using the Finder's Column View, you'll be looking at the files of your Workflow. In that case, go to the menubar and click GoEnclosing Folder () to ensure you're selecting the folder of the Workflow.

  1. Right-click your Workflow in Alfred Preferences again and Export.... Save it to your Desktop.
  2. Drag and drop both into the browser window.
  3. You will be redirected. Press Commit changes at the bottom of the new page.
  4. Redirected again, to the main page. On the bottom division you'll see a preview of your At the moment it contains the name of your repository in big letters. Click the pencil icon to the right to edit it.
  5. The file uses Markdown. If you don't know what that is, don't worry about it and write normally. Describe what your Workflow does and how to use it. Use the About this Workflow text as inspiration.
  6. Click Commit changes at the bottom.

You're done! It gets easier with practice. Learning how to edit your work is left as an exercise to the reader, as are more advanced tasks like releases. GitHub has text and video guides to help you.

Part 2: Sharing the Workflow

Finally, the easy part. Share your Workflow on the official Alfred Forums. For the description, get inspiration from the GitHub's README. Include the link you saved in step 3.

To be extra helpful, include a direct download of the Workflow. To get the link, click the .alfredworkflow file in your repository's main page and copy it from Download or View Raw.

That's it! You've learned the basics of sharing a Workflow for prosperity. Thank you for being part of the community.

Latest Blog Post:

Using macOS Shortcuts with an Alfred workflow

CacheFly Campaign Monitor

"Alfred" is a registered trademark of Running with Crayons Ltd. ©2022 Running with Crayons Ltd. All rights reserved.

Terms & Conditions, Privacy Policy, Cookies.