Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Pry Support #46

ryanb opened this Issue August 21, 2011 · 8 comments

8 participants

Ryan Bates Gabriel Horner John Mair Robert Bialek harryhorn Ches Martin ebbflowgo shshank jain
Ryan Bates

Is Pry supported? I tried Hirb.enable but it doesn't look like it worked. If it is supported, maybe provide some docs.

Gabriel Horner

Hirb currently supports irb and ripl. I'm not looking to add and support more shells. This could probably be done as a pry plugin. To give you an idea of what's needed, here's the ripl plugin. Basically you need to Hirb.enable and then extend whatever Pry method that formats the resulting object of a shell operation: Hirb::View.view_or_page_output(object) || original_pry_method(object)

John Mair


I haven't tested this but try putting something like this in your .pryrc:

require 'hirb'

Pry.config.print = proc do |output, value|
  Hirb::View.view_or_page_output(value) ||, value)
Robert Bialek

Thanks for sharing - your solution works perfectly!

Ryan Bates

@banister awesome, thanks for the code! That is simple enough that I don't think we really need a plugin. Closing this issue, but it might be nice to document this somewhere. Maybe the Pry wiki would be a better spot?

Ryan Bates ryanb closed this August 22, 2011

The suggestion works but is missing one line. Here is the complete code:

require 'hirb'


Pry.config.print = proc do |output, value|
  Hirb::View.view_or_page_output(value) ||, value)
Ches Martin
ches commented August 28, 2011

One more iteration -- I've expanded it to the following semi-dirty hack in my .pryrc, because there are often times that I want to toggle Hirb off for a moment with Hirb.disable:

  require 'hirb'
rescue LoadError
  # Missing goodies, bummer

if defined? Hirb
  # Dirty hack to support in-session Hirb.disable/enable
  Hirb::View.instance_eval do
    def enable_output_method
      @output_method = true
      Pry.config.print = proc do |output, value|
        Hirb::View.view_or_page_output(value) ||, value)

    def disable_output_method
      Pry.config.print = proc { |output, value|, value) }
      @output_method = nil


I've updated the Pry wiki FAQ entry.


Awesome stuff.

shshank jain

Using Rails 3.2.12. Have added pry to Gemfile along with hirb. The above fix doesnt seem to be working.

puts Hirb::Helpers::AutoTable.render(User.first) 


Update: I must be high on caffeine or something, I tried @harryhorn trick again and it worked :)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.