分页IRB或Rails控制台输出的通用方法(Generic way to paginate output of IRB or Rails console)

对于一个“屏幕”,IRB命令的输出通常太大(即使我向上滚动 - 我使用的是Windows - 我无法进入输出的开头)。

是否存在通过IRB / Rails控制台输出滚动/分页的通用方法。 在Unix中,您使用“| more”或“| less”来执行此操作,但这在IRB中不起作用。

我现在使用的解决方法是在枚举上应用范围,例如:

puts YAML::dump User.methods.sort[0..50] puts YAML::dump User.methods.sort[50..100]

等等...

我也看过额外的插件来安装或monkeypatching IRB ,但我想知道是否有本机内置的东西......

The output of an IRB command is often too large for one "screen" (even if I scroll up - I am using Windows - I cannot get to the start of the output).

Is there a generic way to scroll/paginate through the output of IRB/Rails console. In Unix you use "| more" or "| less" to do so, but that doesn't work in IRB.

The workaround I am using now is to apply ranges on enumerables, example:

puts YAML::dump User.methods.sort[0..50] puts YAML::dump User.methods.sort[50..100]

etc...

I've also seen extra plugins to install or monkeypatching IRB, but I was wondering whether there was something natively built in...

最满意答案

你可以使用hirb ,它是irb的一个小型扩展库,它具有其他附魔的分页 。

You can use hirb, it's a small extension library for irb and it has pagination among other enchantments.

分页IRB或Rails控制台输出的通用方法(Generic way to paginate output of IRB or Rails console)

对于一个“屏幕”,IRB命令的输出通常太大(即使我向上滚动 - 我使用的是Windows - 我无法进入输出的开头)。

是否存在通过IRB / Rails控制台输出滚动/分页的通用方法。 在Unix中,您使用“| more”或“| less”来执行此操作,但这在IRB中不起作用。

我现在使用的解决方法是在枚举上应用范围,例如:

puts YAML::dump User.methods.sort[0..50] puts YAML::dump User.methods.sort[50..100]

等等...

我也看过额外的插件来安装或monkeypatching IRB ,但我想知道是否有本机内置的东西......

The output of an IRB command is often too large for one "screen" (even if I scroll up - I am using Windows - I cannot get to the start of the output).

Is there a generic way to scroll/paginate through the output of IRB/Rails console. In Unix you use "| more" or "| less" to do so, but that doesn't work in IRB.

The workaround I am using now is to apply ranges on enumerables, example:

puts YAML::dump User.methods.sort[0..50] puts YAML::dump User.methods.sort[50..100]

etc...

I've also seen extra plugins to install or monkeypatching IRB, but I was wondering whether there was something natively built in...

最满意答案

你可以使用hirb ,它是irb的一个小型扩展库,它具有其他附魔的分页 。

You can use hirb, it's a small extension library for irb and it has pagination among other enchantments.