2

When opening nautilus, choose a file and click ctrl+c copy the file into clipboard so that I can paste it in somewhere else in nautilus. And if the file is an image, I can even paste it in libreoffice. I want to know whether I can achieve the same effect as ctrl+c in command line without opening nautilus?

Simon
  • 449

1 Answers1

1

-target is a way for you to describe the content of the selection. In that sense, it's possible to label the selection incorrectly. It has more to do with how the receiving program handles atoms. LibreOffice in your example handles MIME targets.

$ file --mime example.png 
example.png: image/png; charset=binary

$ xclip -selection clipboard -t image/png -i example.png

You can list targets of the current selection with the special atom name TARGETS

$ xclip -selection clipboard -t TARGETS -o  
TARGETS  
image/png

Next example is Nautilus, the selection target is text/plain and a copy/paste has the format:

x-special/nautilus-clipboard
copy
file:///path/to/file.txt

Gives the xclip selection:

xclip -sel clip -t text/plain <(printf %s\\n x-special/nautilus-clipboard copy file:///path/to/file.txt)