1

I have a problem with my Xterm and I can't figure out what is wrong:

I need to enable the option *selectToClipboard in my Xterm to be able to copy text in the terminal.

To do so i firstly tried to "manually" start xterm with the option with the following command: xterm -xrm 'xterm*selectToClipboard: true' which work very well.

Then to enable the option each time xterm is started I put the following line xterm*selectToClipboard: true in my ~/.Xresources and I used the command xrdb -merge ~/.Xresources to update the settings but it doesn't work: Xterm starts but the option isn't enabled and I can't copy text from the terminal whereas all the other options in the Xresources are enabled and work fine.

Does anyone have an idea of what could cause this problem?

statox
  • 2,827
  • 1
  • 21
  • 41
  • Can you confirm the merge worked with `xrdb -query`? –  Apr 10 '15 at 00:33
  • I confirm: the option line `xterm*selecttoclipboard: true` appears in both case (xterm started "manually" or xterm with the option in Xresources) – statox Apr 10 '15 at 00:39

2 Answers2

0

X resources are case-sensitive. The xterm manual documents this as

selectToClipboard (class SelectToClipboard)

Tells xterm whether to use the PRIMARY or CLIPBOARD for SELECT tokens in the selection mechanism. The set-select action can change this at runtime, allowing the user to work with programs that handle only one of these mechanisms. The default is "false", which tells it to use PRIMARY.

The feature was added to xterm in patch #209 (2006). It is not an optional feature. So (assuming you have typed the command-line as given), there are a few possibilities to check:

  • you could be running an older version of xterm. To check this, run

    xterm -v

The -v version option of xterm will have it print a one-line message showing the patch-level along with the configuration for which it was compiled, e.g.,

XTerm(261)
  • The feature can be set/reset using an escape sequence, as noted in XTerm Control Sequences:

    CSI ? Pm h DEC Private Mode Set (DECSET). ... Ps = 1 0 4 1 -> Use the CLIPBOARD selection. (This enables the selectToClipboard resource).

Your shell initialization may have something which sends this sequence.

The xrdb -query is one way to check for resource-settings, but it is not infallible. A better tool would be appres, e.g.,

appres XTerm
appres UXTerm

depending on whether xterm is run with/without the UXTerm application defaults. In contrast to xrdb, appres shows resource settings after taking into account the "app-defaults" files. (It does not see resources applied only to an instance of xterm such as the -xrm option).

tmux has a feature which can interfere with selections (whether to primary or clipboard). That is called set-clipboard, and is commented upon here:

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • My bad I mispelled it in my question but I put it with the capital letters in my `Xresources` (I edited my question). It still doesn't work. I also tried with both `xterm*` and `XTerm*` since I've seen both on the internet but none of it works properly. – statox Apr 10 '15 at 06:31
  • xterm -v gives me Xterm(278) so the feature must be included. Actually I understand that something might send an unwanted sequence when xterm starts up but I don't knox how to figure out who could do that. I don't have a .Xinitrc in my home only a .Xresources which doesn't seems to do that. – statox Apr 11 '15 at 12:38
  • If I had something unexplainable like that, I'd just compile xterm with the debug-trace turned on, and see why. – Thomas Dickey Apr 11 '15 at 13:06
  • Actually I figured out that it's Tmux which messes with the selectToClipboard setting. It does the same with rxvt and when I detach from the tmux session the selection to clipboard works fine. So i'll have to find why it overrides the settings. – statox Apr 11 '15 at 16:25
0

Short answer: just need to add the line bellow in your /etc/X11/app-defaults/XTerm file

*selectToClipboard: true

Long answer: If you look at man pages xterm(1):

man xterm

FILES
   The actual pathnames given may differ on your system.

...
   /etc/X11/app-defaults/XTerm
        the xterm default application resources.

   /etc/X11/app-defaults/XTerm-color
        the xterm color application resources.  If your display supports color, use this
                  *customization: -color
        in your .Xdefaults file to automatically use this resource file rather than /etc/X11/app-defaults/XTerm.  If you do not do this, xterm uses its compiled-in default resource settings for colors.
...

I did not find any reference to a user configuration file to set XTerm application defaults, except for XTerm-color, so I don't think it exists.

ton
  • 3,827
  • 1
  • 42
  • 40
  • Thank you! This should be the accepted answer to many Xterm copy paste questions. –  Aug 25 '17 at 01:59