I am connected over ssh to remote ubuntu and am trying to cat file content on ubuntu 24.04 machine into clipboard on my MacOS.
On my local OSX machine, I ssh into server and execute:
cat /usr/share/doc/apache2/README.Debian | xclip -selection clipboard
This causes an error: Can't open display: (null)
I tried sshing with -X
flag, same problem.
I can copy the files over with stfp, but it would nice to do it with a clipboard instead. Is xclip
capable of doing cross OS clipboard copying?
It is, if both sides run X. Whether X is running on Linux, some BSD, Windows, or macOS (which is basically some BSD) doesn't matter. The problem is that you don't have X on macOS. The implementation of X on macOS is called XQuartz (here's a random link that turned up on Google for running it - I haven't tried it). That said, I don't know how well XQuartz's clipboard syncs with macOS's native clipboard.
What I'd suggest is running
pbcopy
locally. Example:This runs
cat
on the server andpbcopy
on the local macOS system, and both commands will be happy. This is what I do personally (I have SSH connection reuse enabled, so starting another SSH session costs me nothing).