I wrote a small Ruby script which allows me to post my currently-active Safari tab on Twitter, including the possibility of adding hashtags. Here's the code, though you you'll find any updates to the script over here, and a bit more detail can be found in this blog post.

This script uses the RubyOSA bridge for AppleScript support from within Ruby, as well as quite a few other gems (why reinvent the wheel?).

[robg adds: If (like me) you're not a Ruby user, it will take a bit of effort to get this script to work. First, save the above as a text file somewhere on your path and make it executable (chmod a+x tweetsafari.rb). In order to get it working on my machine, I had to uncomment the require 'rubygems' line, and edit the twitter_user = 'your_twitter_username'. I also had to install some of the listed gems from the script. You can do this with the sudo gem install gem_name command. On my machine, I had to install rubyosa, shorturl, and twitter4r in order to get the script to work. Once I had all those bits, though, it worked as described, and tweeted a shortened URL version of my active Safari tab.]

I really think it's better to have a URL-shortening script or service that's separate from Twitter (even though Twitter is my most common use of shortened URLs). A little Googling will find you several solutions that will insert (or put on the clipboard) a shortened version of the frontmost browser window. These are typically launched via Quicksilver, LaunchBar, FastScripts, or utilities like that.

Even more useful are TextExpander snippets that run a script to get and shorten the URL. With one of these, you can just type the abbreviation into whatever Twitter client you use, and out will pop the shortened URL. Mine are here: