clipboard
clipboard copied to clipboard
Windows Subsystem for Linux support
It would be awesome if executing clip.exe
was used as an additional fallback on Linux. That way, in WSL environments where xclip
and xsel
are not installed, text could be copied to the Windows clipboard. Specifically, I'm trying to use gopass
(which uses this library) under WSL.
In cases where someone is running an X server on WSL, the situation gets complicated unfortunately.
not pretty but this is just an one minute hack
var clipPath string
if _, err := os.Stat("/c/Windows/system32/clip.exe"); !os.IsNotExist(err) {
clipPath = "/c/Windows/system32/clip.exe"
} else if _, err := os.Stat("/mnt/c/Windows/system32/clip.exe"); !os.IsNotExist(err) {
clipPath = "/mnt/c/Windows/system32/clip.exe"
} else
p := fmt.Sprintf("Bearer %s\n", re.IdToken)
if clipPath != "" {
sh.Run("bash", "-c", fmt.Sprintf("echo '%s' | %s", p, clipPath))
}
```
I'm tempted to take a stab at this; hub
also uses this library.
@atotto Would a PR that looks for clip.exe
on Linux be accepted (assuming code quality is OK etc, of course)?
This would also solve https://github.com/gopasspw/gopass/issues/1664 on our side 👍
This is what I've done in the past to get around this: https://github.com/e-zk/cpass/blob/master/main.go#L53
Checking the version string in /proc
for "microsoft-standard"^1 may not be the most robust solution for checking whether the distro is WSL.
This works better with WSL https://github.com/golang-design/clipboard