Found a lot of nice extensions for Alfred, but found myself needing to modify existing scripts to better suit my needs, or to maybe fix little issues that existed. This script is based on the one @ mosx.tumblr.com.
Added an easy area to add your Bit.ly username and api key. Noticed the script would give me an API error if the address was missing the [enlighter]http[/enlighter] tag or only used the [enlighter]www[/enlighter] prefix, so tried to have it add a working prefix to the URL. Added a Growl notification, but sometimes it doesn't pop up. Still sorting everything out, but so far its been working okay.
Update:
\#!/bin/bash
\# Configuration:
\# ulog=YOUR\_USERNAME
\# ukey=YOUR\_BITLY\_API\_KEY
\#
\# Get your Username and API key here:
\# https://bitly.com/a/your\_api\_key/
ulog=
ukey=
ulink={query}
if echo \${ulink} \| grep -q -E 'http:\\/\\/\|https:\\/\\/'
then
slink=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink}&format=txt" http://api.bitly.com/v3/shorten\`
echo \$slink \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink
elif ulink2=\`echo \${ulink} \| sed 's/www./http:\\/\\/www./'\`
then
slink2=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink2}&format=txt" http://api.bitly.com/v3/shorten\`
echo \$slink2 \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink2
else
ulink3=\`echo http://\${ulink}\` \|\|
slink3=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink3}&format=txt" http://api.bitly.com/v3/shorten\`
echo \$slink3 \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink3
fi