Quoth Bil Kleb <W.L.Kleb / larc.nasa.gov>
On Sun, 30 Mar 2003 21:31:55 +0900:

> OK, so I admit: I'm stupid.  How do I save the code I've generated
> during an irb session?


I never thought about that before.  You may know that Unix lets you
record any console interaction ...

  % script irb-session
  Script started, file is irb-session
  % irb
  irb(main):001:0> puts 'hello'
  hello
  => nil
  irb(main):002:0> exit
  % exit
  Script done, file is irb-session
  %

... but input and output appear interleaved in the file, so it doesn't
really give you just the code you wrote.  Although you could run the
file through a filter that found code lines based on the prompt pattern,
even then I think it would still have your backspaces and such.

  -- Mark