Customising IRB

 Feb 19, 2013

I only just came across this the other day, so other people using Ruby, at least those new to it, may not know this either.

What’s irb? (Just in case you don’t know)

irb is the interactive ruby shell, and is one of the things that makes working with Ruby so pleasant as you can just pop open a terminal window and try out a little code or check something quickly

You can access it by typing irb in the terminal window

Customising irb

This is for OSX. Afraid I don’t use Windows so not sure how this would translate

Customising irb is dead simple, just create a file in your $HOME directory called .irbrc

Once done, you can require any Ruby classes or gems, or add custom methods here that will then become available in irb (and in rails console too)

Dr Nic has a post about how his irbrc file was setup, which I found very useful

But what really led me to this discovery was the View Source on Ruby Methods blog post over at the Pragmatic Studio blog