Switch to win32yank.exe for clipboard in WSL2

Using `xclip` or `xsel` in WSL2 started causing Windows GUI applications
to hang when pasting from the clipboard set by `xclip`/`xsel` waiting on
input from a clipboard process which had already exited. When WSL is
detected, use `win32yank.exe` instead. This is available via Chocolatey
but is also shipped with the Neovim Windows installation.

For more context, see https://github.com/microsoft/terminal/issues/11945
This commit is contained in:
Kenneth Benzie 2022-12-03 18:40:25 +00:00
parent 6629046ec2
commit 6beb81f972

View File

@ -115,12 +115,14 @@ bind -n WheelDownPane \
\"select-pane -t= ; \ \"select-pane -t= ; \
send-keys -M\" " send-keys -M\" "
# Yank to the system clipboard in copy mode # Yank to the system clipboard in copy mode.
# TODO: reattach-to-user-namespace not necessary with tmux > 2.6
if -b '[ "`uname`" = "Darwin" ]' \ if -b '[ "`uname`" = "Darwin" ]' \
'bind -T copy-mode-vi y send-keys -X copy-pipe \ 'bind -T copy-mode-vi y send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"'
"reattach-to-user-namespace pbcopy"' \ # When not in WSL2 use xsel, when in WSL use win32yank.exe to avoid UI lockups.
'bind -T copy-mode-vi y send -X copy-pipe \ if -b '[ "$WSLENV" = "" ]' \
"xclip -i -sel p -f | xclip -i -sel c"' 'bind -T copy-mode-vi y send-keys -X copy-pipe "xsel -i --clipboard"' \
'bind -T copy-mode-vi y send-keys -X copy-pipe "win32yank.exe -i -crlf"'
# Left status style # Left status style
if -b '[ "$WSL_DISTRO_NAME" != "" ]' \ if -b '[ "$WSL_DISTRO_NAME" != "" ]' \