06/01/11 22:05:06

Shorten URL's with bit.ly and Alfred

I’m slowly digging my way through Don Southard’s Alfred “Pro” Tips.

He wrote a (rather complicated) script to shorten URLs using bit.ly’s API. The script can be shortened to one line and thus doesn’t need any external script file to run from Alfred:

curl -s --data "login=YOUR_USER_NAME&apiKey=YOUR_API_KEY&longUrl=$(pbpaste)&format=txt" http://api.bitly.com/v3/shorten | pbcopy

In case you want to give this command a shiny icon, I would suggest to use the one on their Twitter account rather than their about page.

In case you don’t have a link yet on your clipboard, I would suggest the following (basically Don’s script):

curl -s --data "login=YOUR_USER_NAME&apiKey=YOUR_API_KEY&longUrl={query}&format=txt" http://api.bitly.com/v3/shorten | pbcopy

Don’t forget to run this silently or otherwise you will get annoyed with an open Terminal window.
Here’s how mine looks like: