In the following steps, run xrdb ~/.Xressources
after modifying the X-resources file, then open a new terminal to test the changes.
XTerm
Mouse: Hold CtrlLeft-mouse-click. The "Main Options"
menu shows up.
Select "Print-All Immediately" and release. An XTerm[date]
file with the
terminal contents has been created in your home directory.
Keyboard shortcut: To bind the action to
CtrlShifty, add to your ~/.Xresources
file:
XTerm*vt100.Translations: #override\
Ctrl Shift <Key> y: print-immediate()
Setting the path: printFileImmediate
sets the prefix of the dumped file.
Useful to specify the path of the dumped file. For example, to dump
/home/user/dumps/xt[date]
files,
XTerm*printFileImmediate: /home/user/dumps/xt
Urxvt
Keyboard shortcut: Include in ~/.Xresources
:
URxvt.print-pipe: cat > $HOME/scrollback
Binds to Ctrl+Print or Shift+Print.
Other terminals
Not all of them can do it; check their manual page or menu options.
Beyond script
, a terminal-agnostic solution is to use a multiplexer.
In Tmux, it's a matter of running its internal command
capture-pane -S - ; save-buffer scrollback-file
This in .tmux.conf
would bind it to Ctrl+bCtrl+s:
bind C-s capture-pane -S - \; save-buffer $HOME/scrollback
xdotool
and this sort of black art).