About the author

Steven Harmansteven harman :: makes sweet software with computers!

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

Badges

  • Subtext Project
  • Support Subtext

Tab Completion and Syntax Coloring in IRB

Tab Completion and Syntax Coloring in IRB Again, this is just another little reminder for myself since I keep forgetting how to do it. Anyhow…

If you don’t have tab-completion and syntax coloring in your IRB sessions, you’re missing out! But thanks to both some kick-ass terminals and Ruby itself, you can get both in just a few simple steps.

As easy as 1, 2, done!

Assuming you’ve already got Ruby and RubyGems installed, fire up a terminal window and install the Wirble gem:

gem install wirble

Next, open (or create it if it doesn’t exist) the .irbrc file in your home folder, typically located at ~/.irbrc in Linux, OSX, and Cygwin environments, and add the following:

require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize

Restart your terminal, fire up an IRB session, and enjoy!

Technorati Tags: ,

What others are saying.

# re: Tab Completion and Syntax Coloring in IRB
Gravatar David Mohundro
Nov 13, 2008
Have you seen Utility Belt (http://utilitybelt.rubyforge.org/) yet? It offers this as well, in addition to even more features.

It takes some hacking to get working on Windows unfortunately, but it is pretty nice.
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Michael Letterle
Nov 13, 2008
Dat is sexeh... thanks!
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Jason Meridth
Nov 15, 2008
Nice. Thanks.
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Steven Harman
Nov 15, 2008
@David,
Utility Belt looks sweet... happen to have a link or advice for getting it to play nice on Windows?
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Aaron
Nov 17, 2008

WTF?! This gives me some really weird errors now every time I do script/console or script/server. I know a couple other guys on our team that tried this and is having the exact same problem. No more advice from you, that's for sure.

UNSUBSCRIBE.
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Steven Harman
Nov 17, 2008
@Aaron,
Haha! That's especially funny since I'm one of those other guys on your team experiencing the problems. :)

In any case, Aaron is correct - apparently Wirble is some how colliding with something we are doing in our Rails::Initializer.run do |config| ... end block in our environment.rb.

Bizarre, for sure!
# re: Tab Completion and Syntax Coloring in IRB
Gravatar Aaron
Nov 17, 2008
Yeah, these guys are my team are driving me nuts!
# re: Tab Completion and Syntax Coloring in IRB
Gravatar David Mohundro
Nov 24, 2008
Regarding utility_belt on Windows... it works great in Cygwin :)

If you want to run it from the Windows prompt, you'll have to install the win32console gem and then add a line to your .irbrc to tell it to use win32/console coloring (require 'win32/console/ansi').

It works a lot better in Cygwin!
Comments have been closed on this topic.