Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
end
@bbhoss

This comment has been minimized.

Copy link

bbhoss commented May 9, 2011

Any way to make it automagically puts the inspected return like IRB does? It would be a near perfect replacement if it did this.

@banister

This comment has been minimized.

Copy link
Owner Author

banister commented May 10, 2011

@bbhoss, hey man put this in your ~/.pryrc

Pry.print = proc do |output, value|
  if Pry.color
    output.puts "=> #{CodeRay.scan(value.inspect, :ruby).term}"
  else
    output.puts "=> #{value.inspect}"
  end
end

The next release of Pry will use inspect by default :)

@JoshCheek

This comment has been minimized.

Copy link

JoshCheek commented Jul 10, 2011

What potentially causes the load error?

@banister

This comment has been minimized.

Copy link
Owner Author

banister commented Jul 10, 2011

@JoshCheek, the LoadError could be caused by the pry gem not being installed.

@stephencelis

This comment has been minimized.

Copy link

stephencelis commented Aug 25, 2011

silence_warnings seems rather sloppy, why not:

Object.send :remove_const, :IRB
::IRB = Pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.