is there a way to save what's printed on the display with gnu screen?

There's a logging feature in screen. Start it when you start screen by doing screen -L (or from within screen). Or, also from within screen, you could press Ctrl-a : H.

If you want to have logging on as the default, add the following line to your ~/.screenrc file:

deflog on

You may want to set the filename using something like:

logfile /tmp/screenlog.%n

Option 1: Look into the script command. "man script"

"Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr"

Basically type "script" (no quotes) - do your work, and type exit once to end the session.

Option 2: Use screen's "hardcopy" mode. 'Crtl-a' then 'h' This will save the current session to a file.

note: GNU Screen does have the ability to scroll. Use 'crtl-]' (right square bracket) to enter copy mode, then 'ctrl-b' and 'ctrl-f' to move p and down a page at a time.


It is possible to increase the scrollback and view it in copy mode http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/


You will want to use the 'log' operation, usually bound to Ctrl-a H. This opens a new file called screenlog.N where N is the window number. If the file exists, then output is appended to the file. All output in that window is logged to the screenlog.N file until you deactivate by pressing Ctrl-a H again. You can also get this functionality with Ctrl-a :log. You can change the name using the logfile {filename} command. The file gets placed in the directory in which screen was first started, but that can be changed with the logfile command or with chdir [{directory}].

Note that this is not the same as hardcopy or the scroll buffer. This is the same functionality as the script(1) program, but tied to a single window and without calling a new program.

If you want to save the entire contents of the scroll buffer, use Ctrl-a ] g <space> G <space> Ctrl-a :writebuf This saves the scroll buffer to the file /tmp/screen-exchange. if you want to save only a portion, then change the 'g' and 'G' to other movement keys.