From 6beb81f9726edd81ad7a028dcd1b65b0d1048dbc Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 3 Dec 2022 18:40:25 +0000 Subject: [PATCH] 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 --- tmux.conf | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tmux.conf b/tmux.conf index efae023..f2deda4 100644 --- a/tmux.conf +++ b/tmux.conf @@ -115,12 +115,14 @@ bind -n WheelDownPane \ \"select-pane -t= ; \ 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" ]' \ - 'bind -T copy-mode-vi y send-keys -X copy-pipe \ - "reattach-to-user-namespace pbcopy"' \ - 'bind -T copy-mode-vi y send -X copy-pipe \ - "xclip -i -sel p -f | xclip -i -sel c"' + 'bind -T copy-mode-vi y send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"' +# When not in WSL2 use xsel, when in WSL use win32yank.exe to avoid UI lockups. +if -b '[ "$WSLENV" = "" ]' \ + '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 if -b '[ "$WSL_DISTRO_NAME" != "" ]' \