Quicksilver actions the easy way
by Martin on 9/12/2008![]()
Just encountered bliss deep down in the Quicksilver Google Groups forum. I was trying to save myself a keystroke as usual. More specifically; I often open folders and files in TextMate, and the steps for doing so with Quicksilver are
- 1: Type the first few letters of the folder/file.
- 2: Tab over to the next pane and type “wi” to bring up “Open with” instead of “Open”.
- 3: Tab over to once more and type “te” to bring up TextMate.
- 4: Hit return.
Which is, I suppose, not too bad. However I wanted the flow to be more like this:
- 1: Find the folder/file
- 2: Type in “wi” to bring up a custom action to open the file in TextMate.
- 3: Hit return.
No, it’s not a major step but every single keystroke matters. And besides; This specific action isn’t really the point here.
The point is that to my amazement there wasn’t any simple way to assign a abbreviation to this type of action. That is; an action that needs input in more than one pane. Being a stubborn bastard I started sniffing around on how I could create my own Quicksilver plugin to perform this seemingly simple task. It seemed however that to create a Quicksilver plugin the way to go was Objective-C which I don’t know (the books are shipping from Amazon as we speak). I sat down to make a go at it in XCode, but I just had to give up before I broke something.1
Then; Severely undocumented for such a wonderful feature, it turns out that Quicksilver commands can be written in AppleScript. I don’t mean the fact that you can run AppleScripts from Quicksilver, although that’s nice as well. You can actually create commands that’ll behave just like the native commands in Quicksilver, such as “Reveal”, “Copy to…” or “Go to path in Terminal”. With AppleScript being a ridiculously easy language to get started with 2, this is huge news.
It means that instead of getting to grips with the intimidating world of XCode, my problem could be solved in four human-readable lines:
1 2 3 4 | on open these_items tell application "TextMate" to open these_items tell application "TextMate" to activate end open |
The trick is in the opening line
1 | on open these_items |
refers to the current selection in the first pane, and after that you can use the variable
1 | these_items |
to manipulate with AppleScript all you want. When you’re happy with your script, copy it to ~/Library/Application Support/Quicksilver/Actions and restart Quicksilver. You might also want to go into the Quicksilver preferences and give it a higher priority, or alternatively assign it to an abbreviation.
Have fun!
No comments yet.