2

I have awesome_print configured to be my default formatter in IRB (using AwesomePrint.irb! in my .irbrc) and while this is normally awesome, I want to turn it off sometimes. Anybody know how to from a running IRB/Rails console?

bheeshmar
  • 3,125
  • 1
  • 19
  • 18
  • What are you using to utilize `awesome_print` gem? Avoid using `ap` in IRB for example, then you simply don't use it. What does your `.irbrc` file look like? or is it simply a `require 'awesome_print'` entry? – vgoff Dec 16 '13 at 22:49
  • @vgoff: My .irbrc has "require 'awesome_print'; AwesomePrint.irb!" which replaces all my IRB output with AwesomePrint formatting. That's what I want to disable from time to time without restarting the session. – bheeshmar Dec 17 '13 at 17:04

1 Answers1

8

You can paste this in to you terminal to reset it back to what it was originally if you like:

IRB::Irb.class_eval do
  def output_value # :nodoc:
    printf @context.return_format, @context.inspect_last_value
  end
end

or you can go whole hog and monkey patch AwesomePrint:

module AwesomePrint
  def self.un_irb!
    IRB::Irb.class_eval do
      def output_value # :nodoc:
        printf @context.return_format, @context.inspect_last_value
      end
    end
  end
end

Then just call it whenever you want: AwesomePrint.un_irb!

Kori John Roys
  • 2,621
  • 1
  • 19
  • 27
  • Thanks, I was afraid it was something like this. Maybe I'll add a feature request to AwesomePrint to add this functionality. – bheeshmar Dec 17 '13 at 17:07