Copy from Ubuntu VM terminal into clipboard and paste to Windows without using mouse

Posted on

Problem :

I have this nice alias which works well within my Ubuntu when I need to copy some terminal output right into my clipboard:

alias xclip='xargs echo -n | xclip -selection clipboard'

Now something like cat myfile | xclip and I have output in the clipboard ready to be pasted within Ubuntu, which is really handy.

However, this does not work if I want to paste into my Windows 10 host (I am using Ubuntu VM). I always select and Ctrl+Shift+C, but I would love to be able to copy command output straight into clipboard just like selecting and Ctrl+Shift+C. Is there similar thing to xclip where I can copy/paste from Ubuntu to Windows 10 without mouse selection?

Solution :

Using the primary clipboard as target works for me (Ubuntu). I can paste the string into my VMware host (provided that clipboard sharing is configured correctly):

echo hello | xclip -selection p

or shorter:

echo hello | xclip -i

Leave a Reply

Your email address will not be published. Required fields are marked *