Created
December 9, 2011 16:59
-
-
Save jtbrough/1452378 to your computer and use it in GitHub Desktop.
shortens the uri in clipboard using bit.ly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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