From: Zev Blut Date: 2004-08-30T13:08:52+09:00 Subject: Re: Saving IRB state (Was: Typos) Hello, On Sat, 28 Aug 2004 18:55:55 +0900, Lothar Scholz wrote: > And a huge problem is that copying code fragments into IRB is easy but > if you want to get some code you typed in IRB multiple lines) getting > this back to the editor is much more difficult. If you are not afraid of a bit of text cutting, then it is not that difficult. Here is a simple addition to IRB that will save your session to a file. Add this to your .irbrc file and when you want to save what you have done to disk type "IRB.save_session("your_filename")". # An extension to IRB to save the session to a file # filename: is the name of the file to save the session in # hide_IRB: is a command to suppress output of IRB class method calls. # to prevent execution of the session in Ruby from giving errors. def IRB.save_session(filename,hide_IRB=true) file = File.open(filename,"w") file.puts "# Saved IRB session for #{Time.now}","" Readline::HISTORY.each do |line| next if line =~ /^\s*IRB\./ && hide_IRB file.puts line end file.close end Something like this may have been mentioned before, but if not I hope someone finds it useful. Best, Zev