unable to paste with xclip outside of terminal
I am trying to copy from the terminal with xclip and paste it into the unity desktop environment into gedit text editor. I can copy and paste with xclip in terminal:
$ cat line-size.c | xclip
xclip -o > input5.txt
cat input5.txt
#include <stdio.h>
...
However, when I press control + v to paste into gedit, it only pastes the actual last thing I copied within unity desktop, such as something from firefox browser.
How can I paste in gui applications something I copied from 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.