Check if wslview exists and use it over xdg-open for WSL2

This commit is contained in:
Johan Westling 2020-07-23 10:05:11 +03:00
parent 78203515fd
commit 7f83927fd2
1 changed files with 2 additions and 2 deletions

View File

@ -9,8 +9,8 @@ import (
func getBrowserCmd(url string) *exec.Cmd { func getBrowserCmd(url string) *exec.Cmd {
// Check for Windows Subsystem for Linux (v2+). // Check for Windows Subsystem for Linux (v2+).
if os.Getenv("WSL_DISTRO_NAME") != "" { if _, err := os.Stat("/usr/bin/wslview"); err == nil {
return exec.Command("rundll32.exe", "url.dll,FileProtocolHandler", url) return exec.Command("wslview", url)
} }
return exec.Command("xdg-open", url) return exec.Command("xdg-open", url)