Here's how: you can use the script(1) command (part of the bsdutils package).
- Start the
scriptcommand. Without parameters the sessions will be logged to a file calledtypescript. You can also supply a filename on the command line:script mysession.log. - Type whatever you want to record...
- End the recording session with
exitorCTRL-d. - You can now view the file with
less -r mysession.log(it contains line feeds, escape sequences etc., so a simple text viewer will probably display garbage). You can even print it with lpr(1). Or simply display it on the terminal withcat mysession.log.
An even cooler feature is that you can replay a script with the correct timing information:
- First you have to also record the timing information using the
-tswitch:script -t 2>mysession.timing mysession.log. - You can then replay the script:
scriptreplay mysession.timing mysession.log.
See the script(1) and scriptreplay(1) manpages for more details.