I use echo "stuff" | xsel -b to put "stuff" on my clipboard.

Commonly I use it for output of other commands, e.g.

realpath "./file" | xsel -b

I'm able to directly paste this in some GUI apps (e.g. my browser -- firefox), but not in some other apps (e.g. my IDE, it pastes nothing). But if I paste it in my browser, copy it again from there and try to paste it to my IDE, that seems to work.

What can be an explanation for this?


How do you paste? There are two different clipboards (not exactly the correct term, but close enough).

This is from man xsel

The  X  server maintains three selections, called PRIMARY, SECONDARY and CLIPBOARD. The PRIMARY selection is conventionally used to implement copying and pasting via the middle mouse button. The SECONDARY and CLIPBOARD
       selections are less frequently used by application programs. This program operates on the PRIMARY selection unless otherwise specified.

You can try echo "xxx"| xsel and echo "yyy"|xsel -b. Then when you try to paste it for example to terminal, you get one text with shift-ctrl-v and other with shift-ins.

So it depends on which selection is used by which application.

  • I tried pasting in other applications using both ctrl+v and shift+ins and got the behavior that I described in the question. If I redirect to xsel instead of xsel -b, then I'm not able paste anywhere (old clipboard value gets pasted), even in my browser. – Peeyush Kushwaha Feb 15 at 5:50

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.