If you use Twitter you probably use TinyURL to shorten your URLs pretty often, I looked into doing this with Quicksilver, there are a couple of blog posts that show you how to do it, but none of them I really liked. One even said it was crap himself in the beginning of the post.
What I really want is this:
- I would copy the URL I want to shorten to my OS X clipboard
- I run something in Quicksilver
- The clipboard will be updated with the shortened URL
This turned out to be extremely easy to do. Here’s a Ruby script that does exactly that. If you make the script executable, Quicksilver should include it in its catalog. So just copy a long URL into your clipboard (⌘-C), invoke Quicksilver, type the filename (I just type “tiny”), and wola, your clipboard will have the TinyURL so you can paste (⌘-V) it into wherever.
#!/usr/bin/env ruby require 'net/http' require 'uri' def shorten(args) action = 'http://tinyurl.com/create.php' field = 'url' url = args[:url] code = 200 Net::HTTP.start('tinyurl.com', 80) do |h| r = h.post(action, "#{field}=#{url}") URI.extract(r.read_body).grep(/tinyurl.com/)[4] if r.code == code.to_s end end IO.popen('pbcopy', 'w').puts "#{shorten(:url => IO.popen('pbpaste', 'r+').read)}"







March 4, 2008
I’m no fan AppleScript’s, but this is a situation where it really is the best solution. Look toward the bottom of this post
http://www.leancrew.com/all-this/2007/11/long-and-shortened-url-scripts/
to find a 5-line AppleScript that does what you want. It uses Metamark, but changing to TinyURL would be a quick edit.
March 4, 2008
not bad, thanks for sharing.