Command Line Clipboard Access

Adr*_*der 10 command-line clipboard

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
Run Code Online (Sandbox Code Playgroud)

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.

主要目标是将内容粘贴到 Firefox 或我正在使用的任何其他基于 GUI 的程序中。

Ser*_*gey 16

嗯,X 中有几个不同的剪贴板 :)xclip默认情况下将文本复制到“选择缓冲区”中的一个是“选择缓冲区”-通常您只需用鼠标选择一些文本,然后就可以用鼠标中键粘贴它。此缓冲区与您可以使用 Ctrl-Shift-V 粘贴的缓冲区是分开的。

尝试

echo "hello" | xclip -selection clipboard
Run Code Online (Sandbox Code Playgroud)

另见

man xclip
Run Code Online (Sandbox Code Playgroud)

有关 xclip 的更多详细信息

  • 仅供参考,也可以缩写为`xclip -sel clip`。我个人一直使用它 (2认同)