Alfred: Bitly Script

January 28, 2012

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 @

Added an easy area to add your 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.


  • Tried to add something to deal with no prefix.
  • Still using the 1x version of Alfred, so don't know if there were any changes that would affect anything.
\# Configuration:  
\# ulog=YOUR\_USERNAME  
\# ukey=YOUR\_BITLY\_API\_KEY  
\# Get your Username and API key here:  

if echo \${ulink} \| grep -q -E 'http:\\/\\/\|https:\\/\\/'  
slink=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink}&format=txt"\`  
echo \$slink \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink  
elif ulink2=\`echo \${ulink} \| sed 's/www./http:\\/\\/www./'\`  
slink2=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink2}&format=txt"\`  
echo \$slink2 \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink2  
ulink3=\`echo http://\${ulink}\` \|\|  
slink3=\`curl -s --data "login=\${ulog}&apiKey=\${ukey}&longUrl=\${ulink3}&format=txt"\`  
echo \$slink3 \| pbcopy && /usr/local/bin/growlnotify "Link Created" -m \$slink3