On 06/11/2013 09:41 AM, crankharder (Josh Sharpe) wrote:
> Feature #8515: don't allow irb to dump output for forever and ever
> https://bugs.ruby-lang.org/issues/8515

Agreed, it would be nice to have LESS(1) functionality in irb.

Have you tried the pry gem? It does behave like less (including regex 
searches).

If you want to use irb, there is this snippet for your .irbrc (though it 
seems incompatible with wirble), which abbreviates long output:

# credit to Stian Haklev
class IRB::Context
   attr_accessor :max_output_size

   alias initialize_before_max_output_size initialize
   def initialize(*args)
     initialize_before_max_output_size(*args)
     @max_output_size = IRB.conf[:MAX_OUTPUT_SIZE] || 500
   end
end

class IRB::Irb
   def output_value
     text =
       if @context.inspect?
         sprintf @context.return_format, @context.last_value.inspect
       else
         sprintf @context.return_format, @context.last_value
       end
     max = @context.max_output_size
     if text.size < max
       puts text
     else
       puts text[0..max-1] + "..." + text[-2..-1]
     end
   end
end