You will be provided with a list of options. You can click and drag the node to create the next step in the workflow. In the workflow pane, you will see the Script Filter, which has a small node on the right of it. We don't have a next step configured right now, so let's do that. When an item is selected, the arg value of that item will get passed along to the next step in the Alfred workflow. The title and subtitle are displayed in the Alfred UI, but the arg is not shown. Here is the result of running the script with any argument that is entered. The PHP script will pass the results to the script filter via stdout, so we only need to echo the results, and not return them.
You can see the full documentation on the structure of the item object here. Our items only contain the very basics, a title, a subtitle, and an arg. The script filter needs to receive a JSON object with an 'items' key where items is an array of item objects.
This is the code that I have already pasted into the Script input. However, depending on how you want your workflow to start, you can make the arguments optional and the script will kick off before any argument is entered.įor the Language option, select /usr/bin/php. For this example, the argument isn't important since we're going to hard code items to select. Keep "with space" selected and make the argument required. In this case, I'm going with tgtn since we'll be selecting a Tighten blog post.
Provide a keyword that you would like to use to tell Alfred that you want to run this particular workflow. Right click in the open pane and select Inputs -> Script Filter. The result of the first command is passed along to the second. Think of it like a bash pipe in the command line. It will display a list of selectable items and when an item is selected, it will pass an argument along to the next step in the workflow.
When filling out this form, you can skip the Bundle Id if you won't be sharing this workflow.Ī script filter is one of the more powerful workflows that Alfred has as it allows a lot of customization via a script. Select "Blank Workflow".įor this blog post, I'm making a workflow that searches the Tighten blog. Then click on the the small "+" icon near the bottom of the workflow list panel. Create a new workflowįirst, open the Alfred Preferences screen and click on the "Workflows" tab. It's a simple task, but it's a good first step to grasping the basics of writing a workflow. In this post, we'll build a workflow to select a Tighten blog post from a pre-defined list and open it in the browser.
Never heard of Alfred? It's basically Spotlight search on the Mac, but supercharged, customizable, and extensible. It's also a lot of fun to share workflows with others. Did you know you can use your PHP skills to build a powerful Alfred Workflow? Creating custom workflows can allow you to fully utilize the power of Alfred to save time and automate tasks.