Saturday, March 17, 2007

Quicksilver Trick

Hopefully everybody knows that you can combine Quicksilver with AppleScript to do nearly anything. What's less obvious, but potentially more useful, is that you can combine Quicksilver with shell scripting really, really easily. All you do is put your shell script in your Applications directory, and you can access it from Quicksilver.

For some reason, the shell script I learned this with, I have to hit Cmd-Space, "a" for "Applications," the right arrow to see the list, and then "j" (the first letter in the script's name). I think that's because I didn't actually put the script in Applications; I put it in /opt/local/bin, and put a symlink in Applications. So Quicksilver doesn't get this exactly right -- I can't just type the script's name -- but it's still four keystrokes, where before I had to open the Terminal.

And why should you have to open the Terminal just to run a shell script? With Quicksilver, you don't. This particular shell script, it's written in Ruby. It's for my personal journal, on my laptop. It creates a filename based on the date and then opens the file with TextMate, using TextMate's mate shell command. So if I've written in my journal earlier that day, I start right where I left off, and if I haven't, the file is automatically created. So in a sense, it isn't really even a shell script; it's using Quicksilver and Unix for TextMate automation. Even though the functionality is enabled by a shell script, it's really got nothing to do with the shell itself at all.

This is why I switched back to the Mac -- and wish I'd done it years ago. Being able to integrate custom Unix programming in the classic sense with the kickass software available for OS X is an unbelievably excellent combination.

3 comments:

  1. Yeha, that's nice. Although I had a problem with my (very simple) bash script that just pauses iTunes and turns on the screensaver (to be run with a custom trigger when fetching coffee): it kills Quicksilver.
    Tried with running the screensaver thing with exec and ending with a &, but it didn't work...
    I've switched to an AppleScript to do the same thing and it works.

    as:
    tell application "iTunes" to pause
    tell application "ScreenSaverEngine" to run

    ReplyDelete
  2. - Call up the 'catalog' pane in qs preferences
    - Click on the arrow at the bottom to add a 'File & Folder Scanner'
    - Choose the location of your shell script (My scripts folder is '~/bin')
    - Click the info icon to open the drawer
    - Include folder contents, to the required depth
    - Rescan the catalog source

    Now you can call up the scripts via QS. The first option should be "Run", the second "Run in terminal"

    Viola!

    ReplyDelete
  3. Bless you. I now have hotkeys for mpd. :-D

    ReplyDelete

Note: Only a member of this blog may post a comment.