This is a meta gem which installs some useful irb gems and configures your irb.
gem install irbtools
On Linux, you need xclip or xsel to use the clipboard: sudo apt-get install xclip
On MacOS, you will need growl, if you want to use the g gem.
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 # rubygems is only needed in 1.8 require 'irbtools'
If it does not exist, just create a new one.
It's possible to modify, which libraries get loaded:
require 'irbtools/configure' # here you can modify which libraries get loaded (see below) Irbtools.init
To use irbtools within the rails console, you will have to add irbtools to your Gemfile.
You can put Rails specific configuration in a ~/.railsrc file which gets loaded only in Rails environments.
How to load more or less libraries
You have the following ways:
Irbtools.add_library(lib, in_proc = false, &block)
Edit the Irbtools.libraries, Irbtools.libraries_in_proc or Irbtools.packages arrays directly. If you use the add_library method, you can apply a block which gets executed when the library is loaded.
See rbjl.net/40-irbtools-release-the-power-of-irb or read the commented source files.
Included gems and libraries
wirb colorize output
hirb (active record) tables and custom views for specific objects
fancy_irb put result as comment and more colorization
fileutils (stdlib) cd, pwd, ln_s, mv, rm, mkdir, touch … ;)
clipboard easy clipboard access (copy & paste)
interactive_editor lets you open vim, hack something, and it gets loaded into the current session
sketches another, more flexible “start editor and it gets loaded into your irb session” plugin
zucker nice debug printing (q, o, c, .m, .d) + useful pseudo-constants (Info, OS, RubyVersion, RubyEngine)
ap nice debug printing (ap)
coderay some nice colorful displaying ;)
boson commands repository (commands also work in the shell!)
guessmethod automatically corrects typos (method_missing hook) [not loaded by default]
See the source for a description. These methods are defined directly by irbtools. Each gem may add its own helper methods.
General: ls, cat, rq, rrq/rerequire, ld, session_history, reset!, clear, use_ruby/use, rubies, use_gemset/gemset, gemsets, dbg, Object#ri
Clipboard: copy, paste, copy_input, copy_output
CodeRay: colorize, ray
If you have RVM installed, you can switch your gemset or ruby with gemset and use (use gemsets and rubies to get a list). The gemset can be changed within the session, while changing ruby starts a new one. Please also note that you need to have installed irbtools for that ruby version. I recommend installing it in the global gemset.
You can customize the welcome message with Irbtools.welcome_message=
Wrong display widths?
When using double-width unicode chars, you should need to pass the :east_asian_width = true when starting FancyIrb. It is deactivated because of performance issues.
Nicer ri command
Planned features for 0.9.0 (next main version)
define flexibly, whether library should be loaded on start/on subsession or via autoload
See the irbtools-more package or suggest some useful utilities/tweaks ;)
Copyright © 2010 Jan Lelis, rbjl.net, released under the MIT license.