Not sure if mine is a weird/unusual workflow, but I have a Windows machine, where I use Windows Terminal. I usually ssh into a remote server, using WSL on Windows Terminal. The remote server is running RHEL.
Now I'm having an issue trying to copy to clipboard on the remote server using xclip
. xclip
always returns Error: Can't open display
. Even if I manually set export DISPLAY=:0
it would still give me the same error. I also set ForwardX11 yes
in ~/.ssh/config
but that didn't help either.
The reason I need this is that ultimately I would like to enable select-and-copy in tmux, on the remote server. The .tmux.conf
would look like something like this:
set-option -s set-clipboard off
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip'
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip'
On WSL itself I would just replace 'xclip'
with clip.exe
and it would work. But since this is a remote server running running in Windows Terminal, all Windows executables are not available.
Does anyone know how I could enable this? Thanks in advance!
xclip
can't seem to find the correct$DISPLAY
. Even if I edit some file usingvim/nvim
and yank some text usingy
, it would still give me the errorclipboard: error invoking xclip: Error: Can't open display: :0
.xclip
is involved in this process or why it works. But I'm trying to look for a way with fewer steps that would mirror my workflow on WSL or other Linux distros - select a text using your mouse and the selected text will be automatically copied to clipboard.