Access xterm's scrollback buffer as a file

You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).

Alternatively, there's an escape sequence documented in XTerm Control Sequences:

CSI ? Pm i                                                                      
          Media Copy (MC), DEC-specific.                                        
            Ps = 1  -> Print line containing cursor.                            
            Ps = 4  -> Turn off autoprint mode.                                 
            Ps = 5  -> Turn on autoprint mode.                                  
            Ps = 1  0  -> Print composed display, ignores DECPEX.               
            Ps = 1  1  -> Print all pages.

which could be invoked as

printf '\033[?11i'

But either approach (to write to a file) would need a printerCommand configured.


You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.

Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents

Tags:

Xterm