sending irb session to a file in windows

A

aeggers

I'm looking to send an irb session to a file. How do people do this on
Windows?

Andy
 
A

andy eggers

Thanks, James, this is useful, although it appears that it only
retains the history of commands I enter, without the irb output
(return values, errors, etc). I'm surprised there's no way to send all
of an irb session (input and output) to a file -- if I'm still missing
something, please someone let me know.

For what I want to do (mostly, I just want to pull out snippets from
an irb session to describe code behavior), what works best for me so
far is to put the command prompt in QuickEdit Mode and manually copy
out sections to the clipboard. (I went a long, frustrating time
without knowing about this -- to turn it on, click the mini-command
prompt on the upper left of the command prompt window and adjust
defaults or properties.)

Andy
 
B

Ben Bleything

Thanks, James, this is useful, although it appears that it only
retains the history of commands I enter, without the irb output
(return values, errors, etc). I'm surprised there's no way to send all
of an irb session (input and output) to a file -- if I'm still missing
something, please someone let me know.

As far as I know (and I'm definitely open to the possibility that I'm
wrong here) that's not really possible outside of windows, either. You
can capture the output, but getting both the input and output would be
tricky.

I think your best bet is to just copy/paste the sections as you describe
below. That's what I'd be doing on OSX to accomplish the same thing.

An alternative would be to look at the history stuff James pointed you
at, and edit the part that writes history out to a file to also exec
each line and put its output in the file. My guess is that would get
you most of the way there.

Either way, please share what you figure out :)

Ben
 
B

Brian Candler

As far as I know (and I'm definitely open to the possibility that I'm
wrong here) that's not really possible outside of windows, either. You
can capture the output, but getting both the input and output would be
tricky.

It's easy in Linux:

$ script foo.txt
$ irb
irb>
...
irb> exit
$ exit
$ cat foo.txt

Technically that only captures the output, but since the output includes the
keystrokes you typed echoed back, that's what you see on the screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,240
Messages
2,571,208
Members
47,845
Latest member
vojosay

Latest Threads

Top