Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Subsystem for Linux support #45

Open
rianadon opened this issue Aug 15, 2019 · 5 comments
Open

Windows Subsystem for Linux support #45

rianadon opened this issue Aug 15, 2019 · 5 comments

Comments

@rianadon
Copy link

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.

@k1ng440
Copy link

k1ng440 commented Feb 5, 2020

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))
	}
```

@tomasaschan
Copy link

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)?

@AnomalRoil
Copy link

This would also solve gopasspw/gopass#1664 on our side 👍

@e-zk
Copy link

e-zk commented Jan 13, 2021

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.

Footnotes

  1. https://github.com/e-zk/wslcheck/blob/main/wslcheck_unix.go

@mikutas
Copy link

mikutas commented Sep 21, 2022

This works better with WSL
https://github.com/golang-design/clipboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants