Equipped with some tools discussed at the germany.rb 2010 user group meetup, I’ve played around with my ~/.irbrc and put together a little meta gem for some useful irb tools (github)

Features

Colorized and output as comment by wirb and fancy_irb

and Nice IRB prompt and IRB’s auto indention

prompt and IRB’s auto indention Includes stdlib’s FileUtils: ls , cd , pwd , ln_s , rm , mkdir , touch , cat

, , , , , , , Many debugging helpers: ap , q , o , c , y , Object#m , Object#d ap – awesome_print q – like p , but on one line Object#m – ordered method list (takes integer parameter: level of nesting) Objedt#d – puts the object, returns self (using tap )

, , , , , , “Magical” information constants: Info , OS , RubyVersion , RubyEngine OS.windows? RubyEngine.jruby? RubyVersion.is.at_least? 1.9

, , , Clipboard features: copy and paste also available: copy_input and copy_output for session history

and Call vim (or another supported editor) to edit a file, close it and it gets loaded into your current irb session, powered by interactive_editor

(or another supported editor) to edit a file, close it and it gets loaded into your current irb session, powered by Another way of live loading into irb: sketches

Highlight a string with colorize('string') or a file with ray('path') , powered by coderay

or a file with , powered by Displays ActiveRecord database entries as tables with hirb

Restart irb with reset! or change the Ruby version with the use method and rvm !

or change the Ruby version with the method and ! Includes the current directory in the load path (was removed in 1.9.2 for security reasons, but is pretty annoying in IRB )

) Shorter requiring like this: rq:mathn

And rerquiring with rrq

Try the included Object#ri helper, powered by ori !

helper, powered by ! Access to a lot of more commands with boson – call commands to get started

Screenshots

Setup

gem install irbtools

On Linux, you also need to sudo apt-get install xclip

On MacOS, you can install growl to use the g gem.

Usage

To use it, put the following in your ~/.irbrc file (this file is loaded every time you start an IRB):

require 'rubygems' unless defined? Gem # only needed in 1.8 require 'irbtools'

If it does not exists, just create a new one.

It’s is possible to modify, which libraries get loaded:

# no require 'irbtools' require 'irbtools/configure' # edit libraries using Irbtools.add_library and Irbtools.remove_library Irbtools.start

RVM hint

You can add irbtools to ~/.rvm/gemsets/global and it will be installed automatically for new rubies.

By the way

Sometimes, you need a clean IRB without all the .irbrc libraries. In such a case, just start irb with the -f option and it will suppress loading the .irbrc .

Update

I’ve now released irbtools-more , which installs even more useful gems, which may not build out-of-the-box.

DrX object inspector: Object#see , requires tk

object inspector: , requires Better auto completion, using Bond

Github