Alfred ProTips

If you read this blog then you probably already know how awesome Alfred is and how much I love finding new and creative ways to use it. The developers have just launched version 0.9 [non MAS version] and it is, without a doubt, a game changer. Why? Because they have added the ability to assign shortcuts to scripts for those who have purchased the Powerpack. Let’s stop and think about that for a second, anything that is scriptable, is now launch-able from Alfred with an abbreviated keyword or Global Hotkey. When I got my hands on this version, I went nuts scripting all types of things. Scripts I use to launch with TextExpander or Hazel, seemed even more natural with Alfred. So I’m going to show you some of the ways you can use a handful of these new features while also demonstrating some black belt level tricks with Alfred.

Shorten a URL with

This was the first command I added after getting my hands on Alfred 0.9. I got the idea after the developer asked if someone could do this on Twitter several days prior. Of all the things I wanted to script, I knew this would probably be the easiest, so thats where I started, and then shared it with the developers. The code is simple, one line actually. Here are the settings you will enter under Alfred’s new section Terminal/Shell. Be sure to check the Silent box next to your command in the Terminal Shortcuts window within Alfred to make this script run in the background.

Download extension here: Create Link

To use this tool, simply type gl followed by a URL that you paste in to the Alfred window as shown below. When you hit enter, the shortened link is added to your clipboard.

Create a CloudApp bookmark right in your clipboard:

This one was a bit trickier to figure out. I read through the REST API documentation which was really helpful. So instead of just posting a specially crafted url, this one requires we send formatted JSON, and it returns a result in JSON format. This is a great example of calling an external script with Alfred. In this script I also added a growl notification to let you know the link has been added to your CloudApp account, because you will also run this script as Silent under Alfred’s settings. There is no indication if it fails but the notification is a nice indication that something happened.

Again, just setup your new Terminal/Shell action as shown below (obviously change the path to the script to match your script location). If you want a nice image to go along with it, CloudApp has a great presskit available. I also want to point out that this script functions differently from the command. I did this on purpose to demonstrate the different ways to utilize scripts in Alfred 0.9. With this script, Alfred is not passing the URL as a variable because is reading your clipboard for the URL and creates a shortened Cloudapp link which is then copied to your clipboard. Honestly, this would probably be better just mapped to a Global Keyboard Shortcut, but I will get to that later. Another great tip is, in Safari, use Command + L to highlight the URL bar and you can quickly copy the address of any site you are viewing without taking your fingers off the keyboard, it’s nice. Another great thing about using Alfred for CloudApp links is it works in any app that you can copy a link, no Rain Drop necessary.
[Update] By the time this publishes, CloudApp 1.5 will have been released which has a feature that makes this a bit obsolete, but its finished so I’m not going to remove it :)

Here is the code to add to your script. Be sure to add in your own Username and Password.

Download extension here: Create CloudApp Link

*This script also works well with TextExpander. Just remove the last part of the echo line, “| pbcopy” and TextExpander will simply print the shortened url right where you are typing.

Convert video to AppleTV format:

Ok, this one is by far my favorite. I have used Handbrake forever but have never automated it all. Whenever I download a new TV show or something I always fire up the GUI, select my preset, browse for the file, and wait for it to finish. With this script, I use HandBrakeCLI (which is a separate install, but totally worth it) to do all the heavy lifting. Now I know what you are going to say: Don, you know Handbrake uses ffmpeg for converting video so why not just cut out the middle man and use ffmpeg in your script like the living legend Brett Terpstra? Well for one, I love Handbrake and it does a great job with little configuration. Since I am only using this script for videos on the AppleTV 2, I can use the Handbrake preset for that device and call it a day…(I’m lazy).

So what’s different about this script? Well this one will be run as an Action (a new option in Alfred’s Action Panel) so you will have to check the Action box in the Terminal settings as shown below. I thought about also marking it Silent, but I like seeing the terminal window during the conversion. Here is the general workflow for an Action like this: Select a video > hit the shortcut Control + Command + \ (pulls up Alfred’s Navigation window) > arrow down to your new action labeled Transcode video for AppleTV. Since videos generally take about 10 minutes to convert, not only does this script send a Growl notification, but it will play a System Sound to notify you when your video is done converting.

Download extension here: Convert to AppleTV Format

[UPDATE 6/02/2011 01:49:03PM]

The wise and creative reader, Andreas Heiberg, that fixed this script when I first posted it, has posted his own enhanced version that allows you to queue movies and even shows the conversion status in Alfred’s bar. Very Nice! Check it out here: Alfred: Convert files to an Apple Tv compatible format

Upload file to Amazon S3

You can easily create an Action for uploading to Amazon S3 by installing s3cmd and slightly modifying the shell script from my previous post Scripting S3 Image Uploads. This utilizes a system alert sound, Growl notifications, and when its done uploading it creates a link to your S3 file in your clipboard. It even encodes any spaces to “%20″ so you can paste it right in to your browser, or share it easily! Be sure to check the box to Escape spaces with backslashes for {query} parameter as shown below. Also check the preference boxes for both Silent and Action. What is really sweet is when you start combining these actions in your workflow. Example: Select a file > Bring up Alfred’s File Navigation > choose Upload to Amazon S3 (the link to that file gets copied to your clipboard) > pull up Alfred and type cl > Paste your new CloudApp bookmark to your S3 file anywhere you want. Easy. Be sure to add your S3 Bucket name to the script.

Download extension here: Upload to Amazon S3

Miscellaneous Roundup

I have so many more that I couldn’t squeeze in to this already long post, but here are a few honorable mentions:

Create Custom Shortened URL:

Not much to say about this one, I got a request to publish this from someone on Twitter, so here it is. It functions the same as the example earlier. You do have to add your API and login name to use’s service, but this script worked fine for me. It even used my custom domain under my Pro Account settings with no additional configurations!

Download extension here: Create link

Upload Picture to Picasa

You can install the great GoogleCL and create an Action for uploading pictures to Picasa. The function of this workflow would be similar to the HandBrake example. Be sure to check the box to Escape spaces with backslashes for {query} parameter as shown below:

Run OmniFocus AppleScripts with Global Hotkeys:

3. You can assign any script, including any afore mentioned scripts in this post, to Global Hotkeys (I really could do a whole post just on utilizing this feature). I immediately put this to work with some OmniFocus scripts I commonly use. I also thought this would have been a great option of the CloudApp script since it did not need any input from Alfred but I wanted to demonstrate the different ways to launch a script.

Here is an example of how I am using it:

These are two scripts from Dan Byler. One changes dates to the weekend, and the second one moves dates by a certain amount of days that I specify.

Use Alfred for Window Management:

I actually really like this one, but since I didn’t want to show the code for all 9 scripts I decided to tack it on to the end of the miscellaneous section. This is basically combining Alfred’s Global Hotkey feature with 9 different Applescripts that will resize/relocate the front window to a specific location on the screen, kind of like the app Divvy. As far as I know this only works for one monitor and the height and width of the resolution are static variables so you have to change them to match your own resolution (mine is 1280×800). If you frequent between multiple resolutions, Gruber has a tip for just autodetecting your resolution. I believe this only works for apps that have AppleScript support.

So here is a link to a zipped folder of the AppleScripts you will need:

Window Management AppleScript Download

Here are my settings for this, I just used COMMAND + OPTION + a number:

I really love this new Global Hotkeys feature in Alfred. It is a lot like FastScrips, so those familiar with that program should feel right at home.

Well that’s it for now. Feel free to let me know how you guys are using the new features in Alfred and I’ll update this post. Enjoy!

[UPDATE 5/18/2011 04:02:45PM]

Start a screencast from Alfred:

This one is great. It utilizes Quicktimes’s ability to record your screen. It launches with a screencast cast command. It creates a video in your Movies folder.

Download extension here: Start a Screencast

View MAN pages in instead of the terminal

This one may not apply to everyone but I sure do read a lot of man pages. Its great to be able to get them out of the terminal in a more readable format. From Alfred, just type man followed by one or more terminal commands you want to view man pages for. No Quotes for this one!

Download extension here: View Man page in Preview

I am just going to keep updating this post as I come up with more so stay tuned!

[UPDATE 5/19/2011 09:15:39AM]

Set wallpaper from Alfred action menu

This one is a user request from John Pappas. Similar to the transcode workflow, you select a photo in Finder, pull up Alfreds actions and scroll down to the new Set as Desktop Wallpaper.

Download extension here: Set as Wallpaper

[UPDATE 5/22/2011 03:48:54PM]

Create tasks in OmniFocus with Natural Language

This one is by far my greatest accomplishment. An Alfred script so large it needed its own post. You can find it here:

OmniFocusCLI: Natural Language Tasks from Alfred

[UPDATE 5/24/2011 09:00:35AM]

Share your current song from iTunes or Ecoute

This quick tip takes the current song from either iTunes or Ecoute and formats a #NowPlaying tweet ready to paste in to any Twitter client. It also shows a Growl notification of all the details and for you Ecoute users, the Growl icon is the album artwork for the current track! I just launch it from Alfred with a “np”

Download extension here: Now Playing

Action Shot:

[UPDATE 8/03/2011 09:49:28AM]

Share on Dropbox with CloudApp Short URL

This one copies a file to your Dropbox public folder and creates a CloudApp URL to it. Be sure to update the script with your Cloudapp Credentials and Dropbox ID.

Download extension here: Share on Dropbox

Create Secure DMG from selected folder

Download extension here: Create Secure DMG

Print from Alfred

This one will need to be tweaked with the name of your printer

Download extension here: Print Document

Rename file from Alfred

This will prompt for a new filename. You can enter just the new name or if you want to change the filetype you can enter the new name and an extension.

Download extension here: Rename File

Password Generator for Alfred

This will generate a random password and put it in your clipboard as well as a sticky Growl notification.

Download extension here: Generate Password

Image Dimensions

This action will display the dimensions of the currently selected image

Download extension here: Image Dimensions

Display CPU Temperature

Download extension here: Display CPU Temperature

Compare two files in BBEdit

Download extension here: Compare in BBEdit

Hash a password using project

This one reads the URL from your clipboard, and gets a password from the Alfred input. See for how this hash method works.

Download extension here: Hash a password

Toggle System Files – Visible/Hidden

This one reads the current view status of system files and just toggles it.

Download extension here: Toggle System Files

Convert Image Formats

This one toggles an image format from JPEG to PNG or PNG to JPEG depending on the current format.

Download extension here: Convert Image Format

Change iChat Status

This one toggles your current iChat status in between Available and Away. It also sets a custom status message based on user input from Alfred.

Download extension here: Change iChat Status

Create iOS 5 Reminders Tasks

This is a quick and simple Alfred extension that creates a new basic todo at the end of the “Reminders” calendar. Nothing new or ground breaking here but it is really convenient now that it syncs to the Reminders app on iOS 5. I also added some code to Growl after it finishes, hopefully Growl works (it did for me) but no guarantees!

Here is a link to the Alfred Extension: Create Reminders Task