From: Dr Balwinder S Dheeman Date: 2005-05-10T21:04:31+09:00 Subject: [PATCH] for persistent 'irb' history --------------090005090707040700060300 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, friends! Here are two small patches for irb scripts context.rd and input-method.rb, apply these if anyone wants to make irb history available persistently. Hope that helps, -- Dr Balwinder Singh Dheeman Registered Linux User: #229709 CLLO (Chief Linux Learning Officer) Machines: #168573, 170593, 259192 Anu's Linux@HOME Distros: Ubuntu, Fedora, Knoppix More: http://anu.homelinux.net/~bsd/ Visit: http://counter.li.org/ --------------090005090707040700060300 Content-Type: text/x-patch; name="context.rb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="context.rb.patch" --- context.rb.orig 2005-04-11 17:57:27.000000000 +0000 +++ context.rb 2005-05-06 08:16:14.925942484 +0000 @@ -61,6 +61,7 @@ if (defined?(ReadlineInputMethod) && (use_readline? || IRB.conf[:PROMPT_MODE] != :INF_RUBY && STDIN.tty?)) @io = ReadlineInputMethod.new + at_exit { @io.finalize } else @io = StdioInputMethod.new end --------------090005090707040700060300 Content-Type: text/x-patch; name="input-method.rb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="input-method.rb.patch" --- input-method.rb.orig 2003-03-23 17:58:43.000000000 +0000 +++ input-method.rb 2005-05-06 08:53:56.185883203 +0000 @@ -90,9 +90,23 @@ @line_no = 0 @line = [] + @history = File.join(ENV['HOME'],'.irb_history') + if File.exists?(@history) + open(@history).readlines.each do |line| + HISTORY.push(line.chop) + end + end @eof = false end + def finalize + history = open(@history,'w') + HISTORY.each do |line| + history.printf("%s\n", line) + end + history.close + end + def gets if l = readline(@prompt, true) HISTORY.pop if l.empty? --------------090005090707040700060300--