- For Windows, download MobaXterm or Xming; for Mac, download XQuartz as the X server. After downloading, open the application.
Note that on Mac XQuartz works after I uncheck the
Enable Syncing
, and check it back again. Link And tmux doesn't work well on Mac's default Terminal.app. For sharing clipboard you need to install tmux-yank plugin
- In the server's SSH configuration file located at
/etc/ssh/sshd_config
, enableX11Forwarding yes
. - Based on personal experience, use the X server address provided in MobaXterm and set the Windows environment variable
$env:DISPLAY
to that address. This can be done inEdit System Environment Variables
.
# configure
PS C:\Users\Sberm> $env:DISPLAY="127.0.0.1:0.0"
# check
PS C:\Users\Sberm> echo $env:DISPLAY
127.0.0.1:0.0
- Use ssh -Y @ for X forwarding (or ssh -X @; my Windows computer cannot use this).
- It is required to use a vim that supports X11. I'll use Neovim because it comes with everything, making the installation convenient. On CentOS, you can use gvim (on Ubuntu, it's called vim-gtk). They support X11 clipboard functionality.
# centos
yum install vim-X11.x86_64
# ubuntu
sudo apt-get install vim-gtk
check if gvim supports X11(vim usually doesn't support by default)
> gvim --version | grep clipboard
+clipboard +jumplist +persistent_undo +virtualedit
-ebcdic +mouseshape +statusline +xterm_clipboard
The presence of a plus sign (+
) before xterm_clipboard
indicates support. Additionally, it must support the system clipboard (+clipboard
). The vim-enhanced
package installed via yum on my CentOS 8 system does not natively support clipboard functionality.
-
Also install
xclip
orxsel
for X11 clipboard sharing. -
Open the editor with gvim -v (or vimx). In gvim, use the following command to copy to the system clipboard. Enjoy!
" copy
%y+ " (visual) (if nothing gets selected, copy all the text)
"+y " (normal)
"*y " (normal)
:"+y " (visual)
:"*y " (visual)
" paste
<ctrl + r>+ (insert)
"+p " (normal)
"*p " (normal)
:"+p " (visual)
:"*p" (visual)