15

I ran the minimal Debian installation inside a VirtualBox instance, installed X11 and Awesome window manager manually (without any custom configuration yet) and installed VirtualBox additions as well (and enabled shared clipboard in settings). However, copy-pasting text from xterm terminal still doesn't seem to work: CTRL+C is sent as a signal to a terminal, and Shift+Insert inserts the text that I had selected (which probably means that it got copied to some buffer somehow), but it is still unavailable from the host operating system.

18

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 ~/.Xresources after putting that into the file.

  • 2
    Using xrdb ~/.Xresources will destructively overwrite your default configuration. instead use xrdb -merge ~/.Xresources – xaedes Apr 26 '17 at 12:17
13

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:

4
  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.

  • 1
    Please, read question carefully. "Go to the application in which you wish to paste" — this suggests that you didn't notice that I needed to paste it into the host OS. – Max Yankov Aug 24 '15 at 8:39
  • Sorry I don't have third button on the mouse. using trackball in here – holms Feb 23 '18 at 12:42
2

Turns out, I didn't account for the fact that X11 has two buffers: primary and clipboard. My text from xterm was copied into primary buffer, while I needed it in clipboard buffer.

I was able to fix the problem by installing parcellite package, launching it and configuring it to synchronize two buffers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.