(Alternatives to @Biswapriyo's correct answer)
Using win32yank.exe
Having the .exe in $PATH
:
cat /path/to/file | win32yank.exe -i
Using Neovim
cat /path/to/file | nvim -c 'normal gg_vg_"+yZQ'ggVG"+yZQ' --headless -
Explanation
Neovim uses an external program to interact with the system clipboard, and this specific program varies among platforms. On Windows it uses win32yank.exe
. The -c
option allows to execute a command after the file is loaded, --headless
makes Neovim run without a UI, and the trailing -
indicates to read from standard input. So if you have Neovim already configured in WSL to work with the clipboard, this should also work (doing about the same as just directly calling win32yank.exe).
Configuring Neovim's clipboard in WSL:
https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl