Open mcandre opened 3 years ago
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)
}
}
How does that work with WSL paths?
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 $@
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