Skip to content

Instantly share code, notes, and snippets.

@jtbrough
Created December 9, 2011 16:59
Show Gist options
  • Save jtbrough/1452378 to your computer and use it in GitHub Desktop.
Save jtbrough/1452378 to your computer and use it in GitHub Desktop.
shortens the uri in clipboard using bit.ly
#!/bin/bash
### takes long uri from clipboard, then saves the shortened uri back to the clipboard
### requires pbpaste/pbbiycopy (os x) and a legacy bitly api key
longURI=`pbpaste`
apikey=your_api_key_here
username=your_user_name_here
format=txt
encodedURI="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$longURI")"
curl -s "https://api-ssl.bitly.com/v3/shorten?login=$username&apikey=$apikey&longUrl=$encodedURI&format=$format" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment