Posted tagged ‘one-liners’

Plugging Ruby into Your Brain, revisited…

March 6, 2008

Jesse Newland has an interesting post about how to use Ruby one-liners from QuickSilver, but it wasn’t working reliably for me. Also, I wanted it to show the result in large type, rather than replacing the text of the QuickSilver command prompt. So I tried my hand, even though it relies on passing the Ruby code through AppleScript, and I’m definitely not an AppleScript programmer.

Here’s my version:

using terms from application "Quicksilver"
  on process text ruby
    do shell script "ruby -00 -e '" & ruby & "'" returning result
    show large type result
  end process text
end using terms from

I don’t have any basis for this but an irrational hunch, but I’m hoping that changing the way it returns the result will also help with the reliability. The example one-liner he gave on his page didn’t work for me with his version… let’s see if it works with mine…

(imagine progress bar here)

Whoohoo! It works. It’s possible that I mistyped it when I tried his version, so let me do it again, now that I have a proven snippet in my clipboard.

(imagine another progress bar here)

Whoops! It worked. OK, it must have been a typo on my part… So mine doesn’t really solve anything, it just changes the way the result is displayed.

Come to think of it, although its less flashy, his version has the advantage of making it easy for you to copy the result to your clipboard. Oh well, now we have two versions to choose from. I saved his as “Execute Ruby” and mine as “Execute Ruby–Large Type”.