irb history on ruby 1.8.6

Somehow got irb history broken.

Googling brought a solution

Here’s the simplified version of the fix I’ve came with:

module IRB
  def HistorySavingAbility.extended(obj); 
    Kernel.at_exit{ HistorySavingAbility.create_finalizer.call }
    obj.load_history
    obj
  end
end 

Put it into .irbrc

Turns out that finalizer is not guaranteed to run, so Kernetl.at_exit hook should be used instead, to persist history

Comments