Skip to content

Force output to a pager

Benjamin Thomas edited this page Jan 8, 2017 · 1 revision
  1. Export this env var, from ~/.bashrc for example.

PAGER="less -S"

  1. Put those methods in ~/.irbrc or ~/.pryrc
    def page(active_record_object)
      formatted_output = Hirb::View.formatter.format_output(active_record_object, options: { resize: false })
      inspect_mode = false
      Hirb::View.pager.page(formatted_output, inspect_mode)
    end

    def vpage(active_record_object)
      formatted_output = Hirb::View.formatter.format_output(active_record_object, options: { vertical: true })
      inspect_mode = false
      Hirb::View.pager.page(formatted_output, inspect_mode)
    end
  1. Use as such, from the rails console
  • page BlogPost.all
  • vpage BlogPost.all
Clone this wiki locally