0

How do I copy files (e.g. pictures) to clipboard using bash so that I can paste them into other programs?

If I view an image in Firefox and right click and copy the image, then I can directly paste it into other program like for example telegram using Ctrl+V to send the image. I would like to have that functionality that I could do that from bash too.

I tried using

cat image.png | xclip -selection c

when I then press Ctrl+V in telegram, it pastes

� PNG

as text instead of pasting the image.

Using xclip-copyfile does not work either, it does not change the content of the clipboard that is used when pressing Ctrl+V in telegram at all.

1
  • Does copying the file's full path & name work "good enough"?
    – Xen2050
    Commented Jan 10, 2019 at 6:20

1 Answer 1

0
xclip -selection clipboard -t "$(file -b --mime-type "$img")" < "$img"
1
  • 1
    Although this may help to solve the problem, it doesn't explain why and/or how it addresses the issue. Providing this additional context would significantly improve its long-term educational value. Please edit your answer to add explanation, including the parameters and what limitations and assumptions apply. Thanks.
    – fixer1234
    Commented Jan 11, 2019 at 5:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .