How can I copy text from xterm (Awesome, Debian, VirtualBox)?

X11 uses two buffers: PRIMARY and CLIPBOARD. To copy/paste to the CLIPBOARD buffer you can often use CTRL-C and CTRL-V. You can insert to the PRIMARY buffer by selecting a text and paste from it by pressing the middle mouse button.

If you want to use the CLIPBOARD buffer, put this in your ~/.Xresources file and use Ctrl+Shift+C and Ctrl+Shift+V to copy/paste from/to the CLIPBOARD buffer in xterm:

xterm*VT100.Translations: #override \
                 Ctrl Shift <Key>V:    insert-selection(CLIPBOARD) \n\
                 Ctrl Shift <Key>C:    copy-selection(CLIPBOARD)

You need to run xrdb -merge ~/.Xresources after putting that into the file.


It is not necessary to modify the xterm translations resources to copy data to/from Firefox, unless you prefer to use the keyboard to help with the process.

Since 2006 xterm has a feature selectToClipboard which lets you switch between the PRIMARY selection (standard) and CLIPBOARD (Firefox, etc).

Because some programs do use the primary selection, and some don't, it is a menu entry in xterm (controlmiddle-mouse):

show selectToClipboard in menu-entry

Adapting the suggestion for control-characters like the GNOME applications lets you use the keyboard, and at the same let the menu switch between the two types of selections:

xterm*VT100.Translations: #override \
                 Ctrl Shift <Key>V:    insert-selection(SELECT) \n\
                 Ctrl Shift <Key>C:    copy-selection(SELECT)

although adding shiftInsert might be closer to the original intent:

xterm*VT100.Translations: #override \
                 Shift <Key>Insert:    insert-selection(SELECT) \n\
                 Ctrl Shift <Key>V:    insert-selection(SELECT) \n\
                 Ctrl Shift <Key>C:    copy-selection(SELECT)

A plain controlC is usually assigned to an INTR signal:

$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Further reading:

  • Why can't I select/paste to/from other programs? (xterm FAQ)

  1. Open xterm and highlight the text you want to copy.
  2. Go to the application in which you wish to paste and hover the mouse cursor over the field you want to paste in.
  3. Click the scroll button on your mouse. (on laptops this can be done by pressing left and right click at the same time)

When you highlight text, it copies the text to your primary buffer. Keep in mind that if you highlight any other text before pasting, that text will then replace the previous content in the primary buffer.