Ubuntu – Command Line Clipboard Access

clipboardcommand line

I'm building a command line tool in order to make some of my tasks more efficient. I need to be able to write content to the clipboard, but for some reason it's not working for me.

I've tried installing both xclip and xsel, but both have the same behavior: they can read/write to the clipboard fine, but I cannot access it from the main Ubuntu GUI.

I've also tried it in the terminal…

echo "hello" | xclip

Then if Ctrl+Shift+V, I get my original clipboard entry, not "hello". But, if I try to grab the content from xclip, it works fine.

The main goal is get the content pastable into Firefox or whatever other GUI-based programs I'm using.

Best Answer

Well, there are a few different clipboards in X :) The one xclip copies text into by default is "selection buffer" - usually you just select some text with your mouse and then can paste it with middle mouse button. This buffer is separate from the one from which you can paste with Ctrl-Shift-V.

Try

echo "hello" | xclip -selection clipboard

also, see

man xclip

for more details about xclip