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(url) Net::HTTP.get_response(URI.parse("http://tinyurl.com/api-create.php?url=#{url}")).body end IO.popen('pbcopy', 'w').puts "#{shorten(IO.popen('pbpaste', 'r+').read)}"
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.
not bad, thanks for sharing.
just updated the code to be a lot more concise.
Thanks Ayn, but for um us non-techies, how do you make this work? Do I save the script in the Actions folder under Application Support/Quicksliver/Actions?