How to use Ctrl-Insert to copy from XTerm

keyboard shortcutsxterm

In applications like Firefox CtrlInsert and ShiftInsert work like Ctrlc and Ctrlv (modifying the secondary clipboard), but in XTerm they do not work like the common CtrlShiftc and CtrlShiftv:

  1. CtrlInsert does not change the clipboards, and instead prints literally ;5~ on the current prompt.
  2. ShiftInsert pastes the primary clipboard instead of the secondary.

Can I fix this in .inputrc or otherwise? It would be nice to have two-stroke cross-platform cut and paste shortcuts everywhere.

Best Answer

xterm, whose conventions were established many years before Firefox, and even the web, was invented, is controlled by application resources. These are merged from several places, including files like /usr/share/X11/app-defaults/XTerm, and also information held by the X11 server seen with xrdb -q. You can override these resources by placing, for example, things like the following in the file ~/.Xdefaults:

XTerm*VT100.Translations:       #override\n\
 Shift Ctrl <KeyPress> v: insert-selection(CLIPBOARD)\n\
 Shift Ctrl <KeyPress> c: copy-selection(CLIPBOARD)\n

This binds ctrl-shift-v to inserting the clipboard contents. I'm not clear exactly what you wanted, so check the man page for the functions and the PRIMARY, SECONDARY and CUT_BUFFER0 selections.


You can presumably add (don't forget the backslash on preceding lines):

Shift <Key>Insert: insert-selection(SECONDARY)\n\
Ctrl  <Key>Insert: copy-selection(SECONDARY)\n