HackMake

Alfred.app Customization and Hacks

Alfred has quickly become a go-to application for me to get stuff done. It started off with great core functionality and over the course of beta and launching as a 1.0 has improved and added many features and customizations. A community has grown around Alfred which has led to an abundance of plugins and extensions to be created and shared only making the tool better. I encourage you to check out Alfred if you haven’t, buy the Powerpack, and then once you’ve played around with it a bit, come back and read about how you can hack Alfred’s endless amount of settings, tools, and customizations to tailor its use for you. Here are some of the hacks I’ve made.

Show Alfred With Selection

In the recently released v1.1, Alfred included the ability, upon triggering a special hotkey, to intake text selected in another application as Alfred’s query text. You can even set automatic keywords and where the cursor is positioned to quickly modify your Alfred query. The perfect use-case for this is selecting a product name that you want to search, hitting the Show Alfred hotkey and adding ‘amazon’ in front of the phrase to quickly be on your way Amazon. Another great use is to select a word, trigger your alternate Show Alfred hotkey and add in your keyword to lookup the word’s definition.

To set this up, open up Alfred preferences then Hotkeys and then Add > General > Show Alfred and configure it as you wish.

Global Scripting

Setting up hotkeys allow you to run scripts and open up files and applications from anywhere. My favorite use of this functionality is running a basic Applescript that will paste my clipboard contents into a new BBEdit document. This lets me quickly jump into editing text or starting a new scratchpad the moment I find text I want to do something with.

Here’s that script if you’d like to use it.

Custom Searches

Alfred has a lot of web searches built in but it’s really simple to add custom searches as well. You can use a keyword and the {query} string to add your inputted text into a URL you specify. You can include your {query} into any GET request for things like search engines (google.com/search?q={query}) or inputting an ID in a RESTful webpage.

Two custom searches that I often use are searching within commit messages of a specified Github repo and opening a specific story via ID in Pivotal Tracker.

To set up a custom search for a specified Github repo, use the following URL: https://github.com/user/branch/search?q={query}&choice=grep

choice can be code to search within code, grep to search commit messages, and author or commiter respectively.

By creating the following search URL with the keyword track I can paste in a Pivotal Tracker story ID from a commit message to easily open it in Pivotal Tracker.

<a href="https://www.pivotaltracker.com/story/show/%7Bquery%7D">https://www.pivotaltracker.com/story/show/{query}</a>

There are endless possibilities for custom URLs so try to roll your own for sites you frequently search.

URL Handlers for Twitter.app

Custom searches also allow you to tie into URL handlers, which are used to make hand-offs between apps by using a URL protocol like appname://. This Tweetie iPhone app resource archive shows the methods that were built into Tweetie as well as Twitter for Mac. The main ones I wanted to use are user and search to be able to use Alfred as an input to open up a search or user page in Twitter.app rather than opening Twitter.com.

Creating a custom search using the following search URL will quickly open up a user’s profile that you’ve entered into Alfred, just as it would if you’re in Twitter.app and go File > Go to User.

twitter://user?screen_name={query}

This custom search would open your query in Twitter.app rather than Twitter.com:

twitter://search?query={query}

I find URL handlers very attractive since they provide the inter-application connectivity of the “open web” with the software experience of well-built native apps.

I would love to hear your Alfred hacks, so please share them on twitter or email me at the link below.