diff options
Diffstat (limited to 'lib/irb/context.rb')
-rw-r--r-- | lib/irb/context.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 6f209b596a..d755622f32 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -8,6 +8,7 @@ require_relative "workspace" require_relative "inspector" require_relative "input-method" require_relative "output-method" +require_relative "history" module IRB # A class that wraps the current state of the irb session, including the @@ -151,6 +152,27 @@ module IRB @command_aliases = IRB.conf[:COMMAND_ALIASES] end + def save_history=(val) + IRB.conf[:SAVE_HISTORY] = val + if val + (IRB.conf[:MAIN_CONTEXT] || self).init_save_history + end + end + + def save_history + IRB.conf[:SAVE_HISTORY] + end + + # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code> + def history_file + IRB.conf[:HISTORY_FILE] + end + + # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+. + def history_file=(hist) + IRB.conf[:HISTORY_FILE] = hist + end + # The top-level workspace, see WorkSpace#main def main @workspace.main @@ -554,5 +576,11 @@ module IRB command = command_aliases.fetch(command.to_sym, command) ExtendCommandBundle.load_command(command)&.respond_to?(:transform_args) end + + def init_save_history# :nodoc: + unless (class<<@io;self;end).include?(HistorySavingAbility) + @io.extend(HistorySavingAbility) + end + end end end |