Awaken The Productivity Beast In Alfred – Part 2

In the previous instalment, I covered quite a few topics. Ranging from search and working with URLs to the various little neat features that make working with your Mac all the more pleasurable. As overwhelming as it all may have seemed at the time, I did warn you that there was still more to Alfred. Much more in fact.

So without further delay, let’s continue on our quest and wake this beast from its slumber once and for all.


Like the article? You should subscribe and follow us on twitter.

Why not start by reading the first part of this series – Awaken The Productivity Beast In Alfred – Part 1

System

When it comes to dealing directly with your system, Alfred has a few neat tricks up its sleeve. Once again it comes to the rescue, aiding us in performing menial everyday tasks with grace and ease, all with just a few keystrokes.

System Commands

Default keyword for system actions.

Default keyword for system actions.

Alfred allows you to perform system actions simply by typing their respective keywords. As one would expect, not having to reach for your mouse to perform any of the following actions is a huge timesaver:

  • Activate the screensaver;
  • Show or empty the Trash;
  • Logout, Sleep or Lock your System;
  • Restart or shutdown your Mac
  • Eject one or all mounted drives;
  • Hide or quit apps.

The last two are particularly useful. At the end of the day when you want to quit out of all your apps and eject all your volumes and drives two simple queries and you’re done!

  1. Open Alfred, type quitall to quit all your apps;
  2. Type ejectall to eject all your mounted volumes safely before shutting down.

You can place any volume in a blacklist. That way it won’t appear in the list of Volumes to be ejected and will also be ignored when issuing the ejectall command.

Although there isn’t a hideall keyword that would come in handy sometimes, you can use another little trick to accomplish something similar. Alfred allows you to action all visible results thus allowing you to hide up to 9 apps simultaneously.

  1. Open Alfred preferences, navigate to Advance>Keyboard and near the end you can choose which modifier to use in order to action visible results;
  2. Next, navigate to Appearance>Options and choose how many results you want to see, max is 9;
  3. Now you can type hide and hit the modifier to action all visible results which will effectively hide up to 9 apps at once.

Terminal / Shell

With Alfred you can quickly open a shell in your terminal of choice and execute a command, all in one go. Open Alfred Preferences and under Features>Terminal / Shell choose which terminal app you want to use and the desired prefix (default is >).

  • Running low on memory, simply type:
    >purge
  • An alternative method to start remote access to a system:
    >ssh remote_hostname

File Navigation

A personal favourite is file navigation. You can quickly access and navigate any folder structure on you Mac with this gem of a feature. With the advent of OS X Lion, Apple hid the Library folder, which for most users was a nuisance. Having to go the the menu hold down ALT to access the library was tedious and for many, unnecessary. Fortunately with Alfred it’s a breeze to access it.

Access The Library Folder

  • Open Alfred’s Preferences and in File Navigation>Advanced, choose which key should be used to identify your Home Folder (default is ~)
  • Now summon Alfred and type ~ followed by the letter L and hit enter and as quickly and easily as that you’re in the elusive Library Folder.

Quickly view and access a hidden file

  • Summon Alfred and navigate to the desired folder;
  • Type . (period) and all those pesky invisible files should appear;
  • Choose the file you want and action it
Quick access to hidden files and folders.

Quick access to hidden files and folders.

Easily Navigate Nested Folders

You can easily navigate the folder hierarchy from within Alfred. By default ?? goes into the selected folder and ?? goes to the parent folder. Alternatively you can use ? to go to the parent folder too. While navigating the folder hierarchy you can also type to filter files and folders. There are 3 other methods of quickly getting to a desired file or folder.

  1. Using the already familiar find and open keywords, start typing a folders name and then navigate the folder with ?? and ??;
  2. Choose the file or folder in finder and then trigger the hotkey for Finder Selection (default is ??\) This will open Alfred with the chosen file or folder. In the case it’s a folder you can continue to navigate it;
  3. The Previous Path hotkey (set this in Features>File Navigation>General) will open Alfred on the last path you navigated to.
Filter Folders and Files while navigating with Alfred.

Filter Folders and Files while navigating with Alfred.

Actions And Buffers

I’ve alluded several times to actioning an item but have yet to expand on that concept. Hitting ? will action an item. The result will vary greatly depending on what type of item is selected or if a keyword was used. There are however alternatives to the default action that can be accessed by hitting ? or ?. This will bring up a new list of options such as Copy/Move, Delete and Get Info to name just a few. However, additional options will be available in accordance to the type of item you selected.

Files

  • Open With – Useful to open a file with an app other than the default;
  • Copy Path to Clipboard;
  • Browse Folder In Alfred – This will open Alfred on the files path allowing you to navigate the folder structure from there.

Folders

  • Open Terminal Here – Opens your default Terminal App at the folders path;
  • Copy Path to Clipboard;
  • Open With – Another way of opening the terminal at the selected location or opening in another app other than finder.

Apps

  • Recent Documents – Summon Alfred, type an apps name and hit ? twice to quickly see the most recent documents opened in that app;
  • Show Package Contents – This will show the package contents in Alfred so you can keep navigating in Alfred or open it in finder.
Quickly access recent files for any app.

Quickly access recent files for any app.

Remember, as with about everything else in the results list, you can also filter actions by typing a few letters.

Extensions

Extensions are Alfred’s utility belt of sorts. They allow you the expand on Alfred’s already vast array of possibilities. Basically, if you can script it, Alfred can do it. It’s possible to break Alfred’s extensions into two main groups.

  1. Scripts – where you can use AppleScripts, Automator WorkFlows and finally shell scripts. Shell scripts in turn allow you to call other scripting languages such as python, perl, ruby, etc. So no matter which scripting language you prefer, odds are you’re covered.
  2. Files and Filters – Filters were discussed in Part 1 (Search Scopes And Filters) so I’ll skip it this time around. Files and Groups however are worth mentioning.

Now, if you don’t have any scripting skills you may immediately dismiss this, thinking that it would be of little use to you. While that may be a sound assumption, it couldn’t be farther from the truth. There are already a vast number of user submitted Extensions that cater to a wide variety of needs. All you need do, is peruse the site, download an extension that seems interesting and install it (double click the extension).

If however you do want to create your own extensions, it’s a rather straightforward affair. Click +, and choose the type of extension. Give it a name, and optionally an icon, author and URL. Finally you will be presented with the screen to edit your new extension. Title, Description and Keyword are common fields to all extension types. Now depending on the type of extension chosen, there will be a few differences so let’s break those down.

Just drag an extension onto Alfred to install

Just drag an extension onto Alfred to install

Shell Scripts

Apart from the previously mentioned fields, shell scripts also have:

  • Options > Silent – checked makes your shell script run silently in the background. If you don’t have this checked Alfred will open a terminal window in which the command will be executed.
  • Options > Action – when checked, your extension will appear in the list of item actions, thus allowing you to action an item from the results window. This field is also present in AppleScripts and Workflows.
  • Command – This is where you place the command that will actually do something when the extension is triggered. Just above the text entry window you will see a button, Advanced. Clicking it will present you with additional options pertaining to the execution of your command:
    • Escaping – Escape any special character so it won’t mess with your script;
    • Debugging – Script output can be logged to console making it easier to analyse;
    • Output – If your script returns some type of information, this can be passed to Growl or Notification Centre. To choose which of the two Alfred should use, navigate to Advanced>Notifications.
    • Files – If you have the Action flag active, you can pass multiple files to your extension.
  • Parameter– You can optionally pass parameters to Alfred (should appear in your script as a variable {query}).
    • Auto Detect – Alfred will attempt to determine if there is a parameter by checking to see if there is any text after the keyword and use that as the {query} parameter.
    • No Parameter – Alfred expects no parameter and therefore any text placed after the keyword will tell Alfred that you’re not using the extension. Instead it will probably show some fallback search.
    • Optional Parameter – If you place some text after the keyword, Alfred will use that. If you place nothing {query} will simply be blank.
    • Required Parameter – Alfred expects a parameter for this extension and until it receives some text after the keyword, nothing happens.

AppleScripts

The fields and options available are very similar to those in shell scripts. Notable differences being:

  • Options > Background – When checked, Alfred “spawns a background osascript process, otherwise it uses NSAppleScript to run internally”. (Thanks Andrew for the clarification)
  • AppleScript – As the field’s name implies, this is where you will place any AppleScript that is to be executed. When creating a new extension, Alfred will pre-populate this with lines needed for your AppleScript to use an optional parameter. If you don’t need it then feel free to delete this text.
  • Parameter – Similarly to Shell Scripts, you have Auto Detect, Optional and Required. This field will only be active however if you have your AppleScript wrapped in on alfred_script(q) handler.

Workflows

A workflow extension lets you use Automator Workflows to accomplish tasks on the actioned item. It has most of the aforementioned fields so no need to go over that again. What I would like to draw your attention to is the Workflow field. It has a browse button allowing you to locate your workflow file. However, there is a cleaner way of doing this.

Right click on the extension name and choose Show in Finder. This will open a Finder window showing you the contents of your extension. You can save your workflow to this folder and then simply type in the workflow’s name (include the extension). This way, if you export your extension to share with the rest of the Alfred community, your workflow will be included in the extension package.

Easily embed your workflow in the extension package.

Easily embed your workflow in the extension package.

Filters

Now, although I briefly skimmed over search filters in Part 1, there were some important aspects I omitted. As already explained, you can define a Scope, to limit the results to a certain folder structure and limit the File Types to search for. I also previously mentioned you could pass the actioned item to an extension.

What I didn’t go into at the time was what is hidden under the Advanced button just above the File Types list.

  • Date Range – search for files from Today, Last 3,7, or 30 Days, Files older than 30 days or Any Date.
  • Metadata Fields – Since Alfred uses spotlight’s metadata index, anything spotlight can see, Alfred can also see. You can add additional Metadata Fields (such as OpenMeta Tags – kMDItemOMUserTags). You can negate certain fields, and choose whether Alfred searches for word boundaries or splits each word into a separate query parameter.
  • Accuracy – when checked, Alfred will search from the first character. This will produce more accurate results with greater performance. When unchecked Alfred will prefix your query with a wildcard allowing for greater flexibility.
  • System Files – Whether or not to ignore system files, reducing unnecessary noise and clutter in the results list.

As you can see, search filters allow for great flexibility and customisation. You can tweak them to suit the needs of a very specific search or keep things broad.

File Or Group

The final extension allows you to setup a group of files, folders or apps that will all be opened simultaneously once you trigger the extension. Create it, as you would any other, give a name, description and keyword. Then simply drag any file, folder or app onto the Files list. Drag to reorder and remember that Alfred takes a top-down approach, so the last item in the list will be the last item opened and thus, the frontmost window.

Use File or Group to quickly setup a working environment, opening up all apps and files you may need for a specific task.

Hotkeys

Hotkeys allow you to bind almost any action possible in Alfred to a keyboard shortcut. You can launch files or apps, perform actions, run system commands, activate extensions and much more. Creating a hotkey is easy enough. Simply navigate to Hotkeys click + and choose the desired action

Selected Text

  • Show Alfred – This will summon Alfred and optionally pre-populate the query with selected text. You can also add a keyword and choose where the cursor will be placed. I use this with DuckDuckGo’s !Bang search. I created a hotkey that would summon Alfred with duck as the keyword. Now I just need to add the !Bang I want followed by the search query and I have quick search across hundreds of sites.
  • Web Search and Custom Search – These two options will immediately trigger a search with the selected text. This is also a great and quick way to translate selected text. Just create a web search and choose Translate.
  • Large Type– This option will simply show any selected text in Large Type. You can either have it occupy the whole screen of fit to your text. You can use this in many scenarios:
    • Search for a file, folder or anything really, trigger Large Type and the full path will be shown;
    • Lookup a contact, choose any of the details and trigger Large Type. The email, phone number, etc will be shown;
Nice party trick, but it can be useful too!

Nice party trick, but it can be useful too!

Apps And Files

You can bind a hotkey to any app or file you desire. This is a great way of quickly opening a very common app or file. Click + choose Apps and Files>Application or File. Choose the keyboard shortcut you want, browse to the file or application and you’re done.

Paths and URLs

If you recall, in the previous instalment I mentioned how adept Alfred was at navigating your folders. I also spoke about how well Alfred handles URL Schemes and URLs in general. Hotkeys provide an excellent shortcut to these powerful features.

    • Paths – Click + choose Paths and URLS>Folder Path. Choose the desired keyboard shortcut, the folder you want and then finally choose if you want that folder to open in Finder or alternatively open in Alfred’s File System Navigation. The later will allow you to continue traversing the folder hierarchy from within Alfred. If you adhere to a type of workflow that uses some sort or inbox of action folder, then this is an excellent timesaver.
    • URLS– This is a personal favourite. It’s more powerful and flexible than you could initially imagine. You create this as you do any other hotkey. Then you can give it a name and start adding URLs. Bear in mind that you can leverage the full power of URL Schemes here.
    • Setup Your Working Environment – An alternative and more versatile method of setting up a working environment, is to use URL schemes. You can open any file, folder or app with file://. This method while not as easy to setup as the File or Group Extension, has the added benefit that you can also add URLs to any website or remote host.
    All apps, files and sites I need, a keystroke away!

    All apps, files and sites I need, a keystroke away!

    • Extensions – You can bind any of your extensions to a hotkey. For extension types that accept parameters, you have a field in which you can type the argument. Alternatively you can check Selected text in OS X and any selected text will be passed as an argument to your extension.
    • System Commands & iTunes – Bind a hotkey to a System Command to easily perform any of the actions available to Alfred. Set hotkeys to control iTunes, from Play/Pause, Next/Prev Track, assign ratings and randomise albums.
    • Clipboard – Here you can configure a hotkey to paste the contents of the clipboard as plain text or use a hotkey to trigger a snippet. The downside though is that you can’t use an already existing snippet and have to recreate it.

    Fun Stuff

    Being Mac lovers, we tend to place some value on aesthetics. And while it may be difficult to have a default theme that will please all users, Alfred allows you to tweak it’s look to your heart’s content. Navigate to Appearance>Theme. Choose from the various themes that come pre-installed or create a new one.
    Clicking on the area you want to change will popup the colour picker. Tweak the colour and opacity and watch your changes live in the preview. Alternatively, head on over to http://alfredthe.me and build your theme there. There are a few more things you can tweak appearance wise so look around the other two tabs.

    Can you tell weekends from workdays... :)

    Can you tell weekends from workdays… 🙂

    Alfred tracks its usage and presents this information in an attractive chart, broken down by usage types. While you could contest that this is a great way of seeing whether you’re getting your money’s worth… lets be honest… It’s all about bragging rights! So just click the little twitter icon to tweet your stats.

    Conclusion

    As I said in Part 1 – “Alfred is one of the rare apps that you can get by just fine using the bare minimum” – but the truth is that when you delve in there is a world more to discover. There is a great community behind it creating wonderful extensions, churning out innovative workflows and sharing them with the rest. There are many great resources out there to further your knowledge of Alfred and bring your productivity to all new heights.

    There is plenty more that could be said about Alfred, it’s just that good, and I’m sure I missed a few things. So sound out in the comments with any tips, tricks or workflows you may have.

Leave a Reply

Your email address will not be published. Required fields are marked *