unable to paste with xclip outside of terminal

I think it is just a matter of understanding the different selection clipboards used by the xclip utility

   -selection
          specify  which X selection to use, options are "primary" to use
          XA_PRIMARY (default), "secondary" for  XA_SECONDARY  or  "clip‐
          board" for XA_CLIPBOARD

When you do cat line-size.c | xclip the default behaviour is to copy to the primary X selection buffer - to paste from that buffer, you need to use a mouse middle-click instead of the Ctrl+v combination.

To copy into the clipboard instead, so that you can paste with Ctrl+v, you would need to do

cat line-size.c | xclip -selection clipboard

Just in case if someone is looking for a shortest version without using aliases. By using something|xclip -se c instead of just bare something|xclip you can press Ctrl+V/Ctrl+Shift+V and see a desirable result. Where something — cat somefile.txt for example.

Tags:

Xclip