Unable to copy fast a file to clipboard in a Linux

2019-03-20 02:34发布

问题:

I have not yet found an easy solution to copy your file to a clipboard in Linux, similarly as in Mac by

cat file | pbcopy

I tried to use the following command in Vim unsuccessfully

:copy 1,9999999

to copy the file.

How can you copy a file fast to your clipboard in Linux such that you can then paste it to dpaste?

回答1:

In addition to xsel and xclip already mentioned there is also uclip. From the manual page description:

uclip is a command-line interface to the X clipboard. It either copies text, from FILE or from stdin, to the X clipboard, or prints the X clipboard to std- out. uclip supports Unicode and is locale-aware (in contrast to other similar utilities). uclip was written using Qt.

Update: Apparently uclip was not such a good recommendation because it currently does not work for copying, see here for the problem description (and hopefully a solution some day?).



回答2:

does xclip suits you?



回答3:

The Linux equivalent of pbcopy is xclip.



回答4:

Try xsel. It does wonders, but it doesn't really work with the clipboard, but rather with the X selection buffer.

cat file | xsel

and then you can click the mouse wheel to paste the contents.