Shorten URL’s using Quicksilver

Download this script and drag it into your QuickSilver Actions folder, which is “~/Library/Application Support/Quicksilver/Actions/”. Restart QuickSilver, and then type “.” to bring up the text field, paste or type in your URL, press tab and select ‘Shorten URL’ and hit return. If you have Growl installed you will get a message saying that your URL was shortened, and the shortened URL will be copied to your clipboard.

Script:

using terms from application “Quicksilver”
on process text longURL
— Init
my growlRegister()

— If we didn’t get a text string then grab the URL from Safari
if longURL is “” then
tell application “Safari”
if document 1 exists then
copy the URL of the front document to longURL
end if
end tell
end if

— Format the URL accordingly in case it was types sans http://
if (longURL does not start with “http://”) then
set longURL to “http://” & longURL
end if

— Convert the longURL
set shellScript to (“curl —url "http://is.gd/api.php?longurl=” & longURL & “" “)

set shortURL to (do shell script shellScript)

— Display success message
growlNotify(“Short URL now in clipboard:”, shortURL)

— Open the shortURL in Safari to test it
—tell application “Safari”
—set URL of front document to shortURL
—end tell

set the clipboard to shortURL

end process text
end using terms from

using terms from application “GrowlHelperApp”
— Register Growl
on growlRegister()
tell application “GrowlHelperApp”
register as application “Shorten URL” all notifications {“Alert”} default notifications {“Alert”} icon of application “Script Editor.app”
end tell
end growlRegister

— Notify using Growl
on growlNotify(grrTitle, grrDescription)
tell application “GrowlHelperApp”
notify with name “Alert” title grrTitle description grrDescription application name “Shorten URL”
end tell
end growlNotify
end using terms from
This script was originally posted here. I changed the script slightly to use is.gd instead of xrl.us. You can use the shortener of your choice by changing the following line of code by replacing the is.g API URL with the API URL of your preferred URL shortening service:
set shellScript to (“curl —url "http://is.gd/api.php?longurl=” & longURL & “" “)

7 notes

  1. topinjuryattorney reblogged this from trumcgowan
  2. gorczycajexp593398 reblogged this from trumcgowan
  3. allene-ward reblogged this from trumcgowan
  4. trumcgowan posted this
Comments (View)
blog comments powered by Disqus