A couple more AppleScripts, these help you turn a long URL into a short one using bit.ly. For even more usefulness use Quicksilver triggers or similar to bind these to a hotkey.
Grabs URL from Safai:
tell application "Safari"
set longURL to (get URL of front document)
end tell
do shell script "curl http://bit.ly/api?url=" & longURL
set shortURL to the result
set the clipboard to (shortURL as text)
Grabs URL from the clipboard:
set longURL to (the clipboard as text)
do shell script "curl http://bit.ly/api?url=" & longURL
set shortURL to the result
set the clipboard to (shortURL as text)
This is just what I was looking for cheers
Just a note though, bit.ly changed their API. You need to add in login and API key, so add in these up top
Editor’s Note: account and API key deleted due to unknown privacy issues. If an API key is required you may have to create an account.
and change shell script line to this:
do shell script “curl http://bit.ly/api?url=” & longURL & “&login=” & login & “&apiKey=” & apiKey
That wasn’t my real API key, but cheers :)
Pingback: Shortening URLs via bit.ly from the CLI - blog.scottlowe.org - The weblog of an IT pro specializing in virtualization, storage, and servers