在IRB或rails控制台中启用awesome_print后,如何禁用它



我将awesome_print配置为IRB中的默认格式化程序(在我的.irbrc中使用AwesomePrint.irb!),虽然这通常很棒,但有时我想关闭它。有人知道如何在运行的IRB/Rails控制台上运行吗?

如果您愿意,您可以将其粘贴到您的终端,将其重置为原来的状态:

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

或者你可以全力以赴打补丁真棒打印:

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

然后随时调用它:AwesomePrint.un_irb!

最新更新