Copy/paste does not always work from Firefox to terminal

10,244

Solution 1

In a sense, yes there are two different clipboards (though X11 calls them "selections", and only one of the selections is called “the clipboard”).

In all likelihood, you are thinking of the Primary Selection (an understandable mistake considering that it functions much more like one on Linux distros than it does under Windows or Mac—though, for the record, the same keyboard shortcuts can typically be used to interact with the Primary Selection under Windows and Mac as they are under Linux).

The clipboard is typically controlled via the Ctrl+{c,v} key bindings for Copy and Paste (respectively). The Primary Selection, on the other hand, has several means of interaction. With the mouse, selecting anything automatically places it in the Primary Selection. Then, one can typically middle-click to Paste from it. One can also use the keyboard: {Ctrl,Shift}+Insert may be used for Copy and Paste (again, respectively) from/to the Primary Selection.

Oddly, it seems X's clipboard is not supported by every application. And, though it may seem unfortunate, there is no way to unify the Primary Selection and the Clipboard. However, there are two solutions for you.

  1. Use the Primary Selection
    It is almost universally available and (at least, it my humble opinion) is a fair bit more flexible.

  2. Use an alternative clipboard manager
    There are plenty of third-party clipboard managers out there which offer far more powerful functionality than the built-in.

Just for example, you could use xcmenu or xclip. There are, however, more alternatives than I can count.


A while after writing this answer, I stumbled upon a clipboard manager called clipit. Among other features that can be quite handy, clipit offers the ability to synchronize the Primary Selection and the X Clipboard. This is functionally equivalent to unifying the two selections and has been really nice to have; I imagine it is exactly what you are looking for.

Solution 2

I had this issue with Firefox + uxterm/xterm in FreeBSD. I am not sure if this is related to not using a desktop manager (I am using MWM).

The best solution I have found to this problem is to use:

autocutsel -fork -selection CLIPBOARD
autocutsel -fork -selection PRIMARY

as part of your .xinitrc

Then whenever you use CLIPBOARD or PRIMARY everything is synced, and you can copy (CONTROL+C) from Firefox into an xterm (middle click or SHIFT+INSERT).

Another useful tool to see what is going on is xcb.

Both autocutsel and xcb are classic X11 tools and are usually available in Linux distributions and FreeBSD.

Share:
10,244

Related videos on Youtube

Armand
Author by

Armand

Updated on September 18, 2022

Comments

  • Armand
    Armand over 1 year

    Using st with dwm, depending on the way I select text (e.g. mouse vs keyboard), and where the text is (e.g. document body vs address bar), copying text from firefox and pasting it into st does not always work.

    Are there two different clipboards?

    Is there a way to unify them?

    • Admin
      Admin almost 10 years
      Do you copy with ctrl-c or are you just relying on text-highlighting to copy?
    • Admin
      Admin over 9 years
      This question and the comments there may be relevant: superuser.com/questions/140944/…
  • RodjamsB
    RodjamsB about 2 years
    To clarify right now, it's not working in either copy and paste, and i'm not even using wayland either.