TextMate: Execute Inline Ruby

Wed, Apr 16


When working in TextMate, if you have a one or more lines of Ruby code that you would like to have the interpreter run, without the need for passing the entire file to the interpreter, this tip may be just what the doctor ordered.

For example, when debugging, often times it would be really handy to run a simple script at a specified location in your code to look at a value, call a method on an Object… The key point here is that you can have as little as one line of Ruby processed by the interpreter and the return value will be inserted inline.

This easiest way to get the gist of this is to watch the screencast below:

If you want to insert the results of one or more lines of script, directly into your code, using # => markers is the way to go.

The music in the video is J.J. Cale and the song: Call Me the Breeze.

A longer clip of J.J. Cale jamming:


Is the video offline? All I see is a white, then black screen with no sound.

by ed on May 1, 2008. #

The video should popup in a new window. Do you see the popup window in your browser? The movie is in the QuickTime format, so depending on your system/browser (e.g. non Mac), you may need to install a plugin.

by john on May 1, 2008. #

I’m using Mac OS X and, just like ed, I can see only a white, with movie cursor advancing.

by alex on May 13, 2008. #

Can you try a different browser and let me know if that works? Also, if you follow the link below that should open the movie (without a popup window):


Let me know if that works any better (if so, might be time to ditch the popup window approach).

by john on May 13, 2008. #

I got the blank movie as well. By scrubbing the timeline (eg. moving the playhead back to the beginning), the movie started playing normally.

by vw on May 17, 2008. #

This is a fantastic tip. I work in Ruby quite a bit via TextMate and had never explored this option but it is incredibly useful! Thanks a ton!

by Jeff Powell on May 27, 2008. #