in Mac, Mac apps

Twitter Quicker, Tweeting with Quicksilver

I’ll get onto twitter and tweets in just one second…

If you have a mac and you haven’t tried the Quicksilver application, I seriously suggest you put it on your list of things to do pretty soon. It is a great way of searching your document, music and application using one simple interface that is fast and doesn’t push it’s way to the front and annoy you.

Quicksilver also allows plugins to some of the software you already use everyday. You could email, ftp, create files or play music all with a few keystrokes and without ever touching your mouse.

Quicksilver also plays well with Applescript, so you can create actions which Quicksilver intergrates and waits for you to initiate.

Anyway, I digress. Coda Hale has come up with a simple script which allows you to tweet using only Quicksilver. Much faster than heading over to twitter.com everytime your cat / wife / baby does something funny.

Well after trying it out myself I have come up with a couple of improvements and I want to add the extra steps in that make this idiot proof.

Make sure you are running the latest copy of Quicksilver so I know your experience will match that of mine.

We are going to do this with a made up user ‘johnsmith’ and a made up password ‘mypass’. On with the show:

Open the Keychain Access application [ ~/Applications/Utilities/Keychain Access ] click [ + ] at the bottom and add a new Item with:

Name: tweetjohnsmith
Account Name: johnsmith
Password: mypass

To allow access from Quicksilver using an Applescript we need to change the Access Control too allow two items:
Quicksilver [ ~/Applications/Quicksilver ] and KeyChain Scription [ ~/System/Library/ScriptingAdditions ]
Open the new item and click the Access Control tab followed by add [ + ]

If you have more than one twitter account, add them in the same way, obviously changing the details to suit.

Next step is to create our Applescript to plug into Quicksilver. Open the Script Editor Application [ ~/Applications/AppleScript/Script Editor ] and paste the following code:

using terms from application "Quicksilver"
  on process text tweet
    tell application "Keychain Scripting"
      set twitter_key to first Internet key of current keychain whose name is "tweetjohnsmith"
      set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
    end tell
    set twitter_status to quoted form of ("source=Quicksilver&status=" & tweet)
    set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
    return nothing
  end process text
end using terms from

You need to make one change to the code above ‘tweetjohnsmith’ needs to be the keychain name you gave to your first account. Once you have made that change choose File -> Save As… from the menu and select to save as a script. For location browse to [ ~/Library/Application Support/Quicksilver/Actions ], if the Actions folder doesn’t exist then create it [ New Folder ] and save your file as Tweet johnsmith (changing johnsmith to your first username) and this is what will appear in Quicksilver during the next step.

Ok. Almost there. If Quicksilver is running, restart it or start it if not.

Hit the Quicksilver shortcut you set up. Defaults to Ctrl-Space. Hit period [ . ] and type your tweets text. Remember to limit it to 140 chars. Once you are happy with your tweet text hit tab and start typing ‘Tweet’. You should see your twitter account or accounts. Select which you want to tweet to and hit enter. All done.

If you got it all right above then you should be able to go to twitter and see your new tweet. @username can also be used as part of your tweet.

Updated

If you use growl, another application all mac users should install, you can also be informed of the success of your new tweet by adding a few additional lines to your script.

Replace:

	return nothing

with:

	tell application "GrowlHelperApp"
		register as application "Quicksilver" all notifications {"Tweeted"} default notifications {"Tweeted"} icon of application "Quicksilver"
		notify with name "Tweeted" title "Tweeted" description tweet application name "Quicksilver"
	end tell
	return nothing

Restart Quicksilver, and the next time you tweet you should get a growl message shortly after to show it’s been successfull.