The NeXT Machine Rocks

I just got the new Twitter client from the new Mac App Store. It’s lovely and minimalist and seems to be missing an integrated URL shortener. (Tweetie, upon which this app is supposedly based, offered a choice of three — go figure.)

Fact is, I’m sick of having some apps with URL shorteners and some without and for the mechanism being different from one place to another. Then it occurred to me that this was exactly the kind of thing “Application Services” — you know, that clumsy feature from NeXTStep that’s been in Mac OS X since it was called Rhapsody but no-one ever uses — are for. And I dimly recalled that Automator lets you create services.

So I googled “mac os x url shortener service” and found this. Here’s the AppleScript snippet from that article:

on run {input, parameters}
  set dlstring to ((path to temporary items folder as string) & "shortURL.html")
  tell application "URL Access Scripting"
    download ("" & (item 1 of the input)) to dlstring replacing yes
  end tell
  set x to open for access dlstring
  set aurl to read x
  close access x
  return aurl
end run

I then launched Automator, created a new service, and wasted a bunch of time trying to figure out how to import AppleScripts into Automator. (Apparently you don’t — you use the “Run Applescript” Automator Action.)

Automator in Action

And now I get system-wide URL shortening. (Sadly it’s two levels deep in the global context menu, but at least I know it’s always there.)

P.S. all this work was redundant because the new Twitter client automagically shortens URLs and counts the tweet’s length assuming a shortened URL. But because it does this completely transparently but with no visual indication (e.g. ghosting in the shortened URL or something) it’s not obvious. So while it’s nice to have a URL shortening service that works everywhere on my Mac now, I don’t need it for