Run Script Action

The Run Script action enables you to run commands directly in macOS. The input can be passed in as argv or you can replace {query} with the script.

In Alfred 3, it's recommended that you use argv, as you don't have to worry about correctly escaping the inputted query.

Run Script Action Sheet

If you have yet to edit the script, a sensible default script (based on the language and input type you've selected) will be shown in grey, including the escaping options if using {query}. Click the "Save" button to save this default script, or edit it to suit your needs.

You can open the workflow folder from the square button to the left of the cancel button, which allows you to quickly add images or other items relevant to your workflow. (This button is in every object configuration sheet.)

Script Configuration

Select the language you'd like to run the script in. You can choose from the following interpreters:

  • /bin/bash/
  • /bin/zsh/
  • /user/bin/php
  • /user/bin/ruby
  • /user/bin/python
  • /user/bin/perl
  • /user/bin/osascript (AppleScript)
  • /user/bin/osascript (JavaScript)

You can run scripts sequentially (subsequent instances of your script will wait until the previous one finishes) or concurrently (a new instance of your script is started every time, even if the previous one hasn't finished).

External Scripts

If you select the language as "external script", you can run an external script. If you don't specify an absolute path, Alfred will look relative to the workflow's folder. Ensure that you have the script's execute permission set.

Environment Variables

When the script runs, a number of useful environment variables are populated by Alfred.

Latest Blog Post:

Tutorial: Creating the Fastest Hotkey-Based Web Search

CacheFly Campaign Monitor

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

Terms & Conditions, Privacy Policy, Cookies.