According to :h clipboard-wsl
in neovim,
For Windows WSL, try this g:clipboard definition:
let g:clipboard = {
\ 'name': 'WslClipboard',
\ 'copy': {
\ '+': 'clip.exe',
\ '*': 'clip.exe',
\ },
\ 'paste': {
\ '+': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ '*': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ },
\ 'cache_enabled': 0,
\ }
I have my wsl.conf not to append $PATH, so I modified that so pathes in the script will be full path. My powershell has a space in its path so I'm trying to escape it, but never succeed.
For example,
- Double-quoting the whole path like
'"/mnt/c/Program Files/PowerShell/7/pwsh.exe" ...'
results inE475: Invalid value for argument cmd: '"/mnt/c/Program' is not executable
error. - Quoting just the space like
'/mnt/c/Program" "Files/PowerShell/7/pwsh.exe ...'
results in almost same error except"/mnt/c/Program
is/mnt/c/Program"
. - Escaping the space with
\
like'/mnt/c/Program\ Files/PowerShell/7/pwsh.exe ...'
causes similar error too.
Why does it happen? How can I avoid it?
paste
directly.g:clipboard
dictionary: sourcehut link. And here is the 'wslyank' script: sourcehut link./mnt/c/Windows/System32/paste.exe
. How can I get it?bin/
folder. You can use that instead of 'clip.exe' and 'paste.exe'.