From 4ee1f0fb5de08acd659ec18409fca433d1bf371a Mon Sep 17 00:00:00 2001 From: Gary Tou Date: Fri, 1 Dec 2023 20:32:00 -0800 Subject: [ruby/irb] Implement `history` command (https://github.com/ruby/irb/pull/761) * Implement `history` command Lists IRB input history with indices. Also aliased as `hist`. * Add tests for `history` command * Address feedback: `puts` with multiple arguments instead of `join`ing * Address feedback: Handle nil from splitting an empty input string * Refactor line truncation * Add `-g` grep option to `history` command * Add `history` command to README * Remove unused `*args` parameter * Allow spaces to be included in grep * Allow `/` to be included in grep regex * Handle `input` being an empty string * Exclude "#{index}: " from matching the grep regex * Add new line after joining https://github.com/ruby/irb/commit/3f9eacbfa9 --- lib/irb/extend-command.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/irb/extend-command.rb') diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 514293a438..072069d4c4 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -191,6 +191,12 @@ module IRB # :nodoc: [ :irb_show_cmds, :ShowCmds, "cmd/show_cmds", [:show_cmds, NO_OVERRIDE], + ], + + [ + :irb_history, :History, "cmd/history", + [:history, NO_OVERRIDE], + [:hist, NO_OVERRIDE], ] ] -- cgit v1.2.3