From cc7dabd79577fe6a9eb574bbe55fc7321e0b74f2 Mon Sep 17 00:00:00 2001 From: Sam Zanca Date: Mon, 20 Jul 2026 13:26:44 -0400 Subject: [PATCH] cli: use powershell for browser opening under WSL to handle long urls --- internal/cli/auth_login.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/cli/auth_login.go b/internal/cli/auth_login.go index c26330f..c882b55 100644 --- a/internal/cli/auth_login.go +++ b/internal/cli/auth_login.go @@ -141,9 +141,26 @@ func openBrowser(url string) error { cmd = "cmd" args = []string{"/c", "start", url} default: - cmd = "xdg-open" - args = []string{url} + if isWSL() { + cmd = "powershell.exe" + args = []string{"-NoProfile", "-Command", fmt.Sprintf("Start-Process '%s'", url)} + } else { + cmd = "xdg-open" + args = []string{url} + } } return exec.Command(cmd, args...).Start() } + +func isWSL() bool { + if os.Getenv("WSL_DISTRO_NAME") != "" { + return true + } + data, err := os.ReadFile("/proc/sys/kernel/osrelease") + if err != nil { + return false + } + s := strings.ToLower(string(data)) + return strings.Contains(s, "microsoft") || strings.Contains(s, "wsl") +} -- 2.51.2