How to search XTerm console history

xterm

Is there some way to search XTerm's console history interactively, like Ctrl+Shift+f in GNOME Terminal and Terminator?

I could run script in my .bashrc or possibly even patch XTerm, but it would be nice to know if there is already some shortcut or configuration setting to do this without heavily modifying my runtime environment.

A way to save the entire scrollback buffer in a single operation (that is, without copying every page of it with a mouse) would be an OK fallback.

Best Answer

There's nothing built in, exactly, but there are two ways to get at the scrollback text.

You can configure the XTerm.vt100.on4Clicks and XTerm.vt100.on5Clicks resources (or from on1Clicks onwards, for that matter) to choose to copy the whole scrollback to the X11 PRIMARY selection. For example, to copy the whole scrollback on a quadruple click, put this line in your .Xresources:

XTerm.vt100.on4Clicks: all

You'll then have to arrange your own method for bringing up some way to search the content of the X selection, such as opening an editor or a pager with a window manager binding.

You can call the print-everything action to send the whole scrollback to a program determined by the XTerm.vt100.printerCommand resource. For example, to open the scrollback in less (running in a new xterm) when you press Ctrl+/, put these lines in your .Xresources:

XTerm.vt100.printerCommand: xterm -e sh -c 'less <&3' 3<&0
XTerm.vt100.translations: #override Ctrl ~Meta ~Shift <Key>slash: print-everything()
Related Question