astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.03k stars 73 forks source link

Add -alt-text option to set STRING (for text/html to work in Chrome) #142

Open phillipberndt opened 1 year ago

phillipberndt commented 1 year ago

I would like to propose a new option, -alt-text t, that sets a STRING target in addition to whatever target atom is set from stdin/a file. So the command line

echo -n Bar | xclip -i -sel clip -alt-text Foo -t text/html

will result in Foo being pasted into terminals, and Bar being posted in web browsers.

The reason I'd like to have such an option is that Chrome does not offer the option to paste HTML into text fields unless the STRING atom target is set and non-empty. To be precise, without -alt-text, I cannot paste HTML into a chat in the Slack website running in Chromium.

tonyvfish commented 1 year ago

Is it possible to have multiple mime types using comma separation i.e. text/html,x-special/gnome-copied-files

cameron1729 commented 4 months ago

This also fixes a problem I was facing with Telegram. Previously I could do echo "file:///tmp/export.mp4" | ./xclip -selection clipboard -t "text/uri-list" and then when I did Ctrl + v in Telegram it would paste the video.

After a recent update it stopped working, but with this patch I can do: echo "file:///tmp/export.mp4" | ./xclip -selection clipboard -alt-text whatever -t "text/uri-list" and pasting in to Telegram works again.