From 9293ea218277d18e7c192379b6697c04c89abdc1 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 19 Apr 2019 21:00:22 -0400 Subject: [PATCH] Support google chrome on macOS --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 168d7cf..cf0d82b 100644 --- a/main.go +++ b/main.go @@ -146,6 +146,8 @@ func openBrowser(url string) { openCmd = exec.Command("chromium-browser", fmtChromeOptions(url)...) case commandExists("firefox"): openCmd = exec.Command("firefox", "--url="+url, "-safe-mode") + case pathExists("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"): + openCmd = exec.Command("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", fmtChromeOptions(url)...) default: flog.Info("unable to find a browser to open: sshcode only supports firefox, chrome, and chromium") } @@ -166,6 +168,11 @@ func commandExists(name string) bool { return err == nil } +func pathExists(name string) bool { + _, err := os.Stat(name) + return err == nil +} + // randomPort picks a random port to start code-server on. func randomPort() (string, error) { const (