From 743ef6a1818022e29d6a2b1695f301b34b2e0205 Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Thu, 29 Jul 2021 00:20:57 +0900 Subject: [PATCH] fix: Windows Subsystem for Linux support If the WSL distro has xclip and xsel installed by default, clip.exe won't be used. --- clipboard_unix.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/clipboard_unix.go b/clipboard_unix.go index d9f6a56..3333e57 100644 --- a/clipboard_unix.go +++ b/clipboard_unix.go @@ -60,6 +60,18 @@ func init() { } } + if os.Getenv("WSL_DISTRO_NAME") != "" { + pasteCmdArgs = powershellExePasteArgs + copyCmdArgs = clipExeCopyArgs + trimDos = true + + if _, err := exec.LookPath(clipExe); err == nil { + if _, err := exec.LookPath(powershellExe); err == nil { + return + } + } + } + pasteCmdArgs = xclipPasteArgs copyCmdArgs = xclipCopyArgs @@ -83,16 +95,6 @@ func init() { } } - pasteCmdArgs = powershellExePasteArgs - copyCmdArgs = clipExeCopyArgs - trimDos = true - - if _, err := exec.LookPath(clipExe); err == nil { - if _, err := exec.LookPath(powershellExe); err == nil { - return - } - } - Unsupported = true }