Jeff Mancuso of Strongspace cleaned up some Brett Terpstra shell script fu for quick and dirty hosting and generating shortened URLs on the Strongspace Blog last week.
I’ve been using a similar (much nastier!) script for a few years now, I found it very convenient in training situations to drop files on Strongspace/Dropbox and hand out easy to write URLs to delegates. Seeing the cleaner form of Bretts/Jeffs script has caused me to retire my old hack, but not until I’d switched the URL shortener to bit.ly, my shortener of choice.
So, with appropriate props to the earlier code, here is a bit.ly variation of the code which I posted in the comments over there, but record here for my poor memory:
function sshare () {
scp "$1" ss:/strongspace/your_username/public
url="https://www.strongspace.com/your_username/public/$1"
tiny=$(curl -s --data-urlencode "longUrl=$url" \
--data-urlencode "login=XXXXX" \
--data-urlencode "apiKey=XXXXX" \
--data-urlencode "format=txt" http://api.bit.ly/v3/shorten)
echo $tiny | pbcopy && echo $tiny
}
Where your login and apiKey values can be retrieved from bit.ly after login via the http://bit.ly/a/your_api_key url (bit.ly accounts are free, so if you want a new account signup at http://bit.ly/a/sign_up first!).
To subsequently see click-thru info on the URL that is generated, add a + to the end of the shortened URL.
BTW, now that bit.ly has acquired j.mp, you can drop an all important 2 extra characters out of those URLs as well …