Hirb and IRBTools

The Rails console makes it pretty hard to see whats going on when you dump a model. IRBTools includes Hirb which will format Active Record output into pretty tables. Unfortunately those tables don't resize with the console resizing, but on unixy systems like Linux and OSX you can do a little hack to fix that.

This is my .irbrc file. Some save-history settings and the Signal.trap, which will tell Hirb to resize when the terminal resizes:

1
2
3
4
5
6
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"

Signal.trap('SIGWINCH', proc { y, x = `stty size`.split.map(&:to_i); Hirb::View.resize(x, y) } )

This requires these handy gems in your Gemfile:

1
2
3
gem 'irbtools'
gem 'irbtools-more'

Back

Metadata

Home

Leslie

This is the website of Leslie Viljoen. More info



This website is powered by Rails 4
log in