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

wsl support #29

Open
mcandre opened this issue Nov 19, 2020 · 3 comments
Open

wsl support #29

mcandre opened this issue Nov 19, 2020 · 3 comments

Comments

@mcandre
Copy link

mcandre commented Nov 19, 2020

Note that WSL environments should invoke powershell.exe Start <pth>. I've updated my little karp utility to account for this.

https://github.com/mcandre/karp

@coezbek
Copy link

coezbek commented Jun 24, 2022

A workaround until WSL is supported:

var is_wsl bool = isWSL()

func isWSL() bool {

	if runtime.GOOS != "linux" {
		return false
	}

	cmd := exec.Command("uname", "-a")
	if output, err := cmd.Output(); err == nil {
		if strings.Contains(strings.ToLower(string(output)), "microsoft") {
			return true
		}
	}
	return false
}

func openFile(filename string) error {

	if is_wsl {
		return exec.Command("wslview", filename).Start()
	} else {
		return open.Start(filename)
	}
}

@coezbek
Copy link

coezbek commented Jun 24, 2022 via email

@sstrudeau
Copy link

I ran into this issue when working with fly.io's flyctl command line app in Ubuntu on WSL for Windows. I ended up creating a small shell script and putting it in my path to override the default xdg-open behavior to invoke powershell instead:

#!/bin/sh
powershell.exe /C start $@

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

No branches or pull requests

3 participants