xclip icon indicating copy to clipboard operation
xclip copied to clipboard

Support making text available in multiple X selections

Open jlmuir opened this issue 9 years ago • 3 comments

This is a feature request. I have a situation where I would like to make text read from the standard input stream available in two X selections: the primary and the clipboard. Is that possible?

My use case is that I have RHEL 6 running as a guest VM in VMware, and only the primary selection, not the clipboard, seems to be shared with the host, which is running macOS Sierra. So, I want the text to be available in both the primary selection and the clipboard. That way, I can use one short command or alias to copy, and be able to paste from the clipboard within the guest VM and from the primary selection in the host.

For example, I'd like to be able to do something like this in the guest VM:

$ alias pbcopy='xclip -sel primary -sel clipboard'
$ echo 'text to make available in primary and clipboard X selections' | pbcopy

P.S. Thanks for xclip! Great tool!

jlmuir avatar Feb 02 '17 03:02 jlmuir

Well, I think I'll answer and close my own feature request. It seems xclip can already do what I want by using the -f option! I didn't realize this until now:

$ alias pbcopy='xclip -f -sel primary | xclip -sel clipboard'
$ echo 'text to make available in primary and clipboard X selections' | pbcopy

Thanks!

jlmuir avatar Feb 02 '17 15:02 jlmuir

Hi. Please consider re-opening this issue: the solution you found, chaining several xclip commands together with the -f option works, but it does not allow to specify a limit to the number of pastes. For example:

decrypt_password | xclip -in -selection clipboard -selection primary -loop 1

would allow me to paste the decrypted password only once, either with middle-click/primary or with shift-insert/clipboard.

Cigaes avatar Dec 30 '22 12:12 Cigaes

Re-opening as this is a reasonable request.

hackerb9 avatar Jan 01 '23 05:01 hackerb9