Skip to content

Instantly share code, notes, and snippets.

@fenixkim
Created April 19, 2013 00:20
Show Gist options
  • Save fenixkim/5417225 to your computer and use it in GitHub Desktop.
Save fenixkim/5417225 to your computer and use it in GitHub Desktop.
This is an Automator's URL Shortening service, this gets the selected URL from any application and shorten it using the bittly.com API. You must create a new service workflow from automator and paste the code in a **Run shell script** action of automator. Don't forget update the LOGIN and APY_KEY This is useful to shorten the urls from Dropbox a…
# Gets the input
URL="$(cat)";
# Encode the url using php
URL=$(php -r "echo urlencode('$URL');")
# Shorts the url using bitly api and copy to clipboard
curl -s "http://api.bitly.com/v3/shorten?login=LOGIN&apiKey=APY_KEY&longUrl=$URL&format=txt" | pbcopy
# Plays a sound when finishe
afplay '/Applications/Mail.app/Contents/Resources/New Mail.aiff'
# Prints the results
echo $(pbpaste)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment