Windows is a pain in the arse when it comes to clipboard management. He’s a hacky guide to get access to the Windows clipboard from within Linux using WSL.
-
Install Xming.
-
Create a file called
config.xlaunch
:<?xml version="1.0" encoding="UTF-8"?> <XLaunch WindowMode="MultiWindow" ClientMode="NoClient" LocalClient="False" Display="-1" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="" Wgl="True" DisableAC="False" XDMCPTerminate="False"/>
``
-
Add
export DISPLAY=localhost:0.0
to the end of WSL’s~/.bashrc
:echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
``
-
Enable the Vim clipboard:
sudo apt install vim-gtk
``
-
Check that it got installed properly:
vim --version | grep clipboard > +clipboard
``
-
That’s it!
Troubleshooting
There may be an issue with using WSL 2. If you’ve done everything above but still can’t copy to the keyboard, do this:
-
Open Powershell.
-
Check your WSL version:
wsl -l -v > NAME STATE VERSION > * Ubuntu Running 2 > Ubuntu-20.04 Stopped 2
``
-
WSL 2 is the problem here. Change it to version 1:
wsl --set-version Ubuntu 1
``
-
You should now be able to copy your passwords to the clipboard:
pass -c password
``
-
That’s it!