aboutsummaryrefslogtreecommitdiffstats
path: root/browserenv.go
diff options
context:
space:
mode:
Diffstat (limited to 'browserenv.go')
-rw-r--r--browserenv.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/browserenv.go b/browserenv.go
index 8685fc8..2a7abcd 100644
--- a/browserenv.go
+++ b/browserenv.go
@@ -3,6 +3,7 @@ package browserenv
import (
"io"
"os"
+ "os/exec"
"github.com/pkg/browser"
)
@@ -19,5 +20,32 @@ func OpenReader(r io.Reader) error {
}
func OpenURL(url string) error {
+ envCommand := envBrowserCommand()
+ if envCommand != "" {
+ return runBrowserCommand(envCommand, url)
+ }
+
return browser.OpenURL(url)
}
+
+// TODO
+func envBrowserCommand() string {
+ return os.Getenv("BROWSER")
+}
+
+// TODO
+func runBrowserCommand(command, url string) error {
+ return browserCommand(command, url).Run()
+}
+
+// TODO
+func browserCommand(command, url string) *exec.Cmd {
+ shellArgs := shell()
+ shell := shellArgs[0]
+ args := shellArgs[1:]
+
+ command = fmtBrowserCommand(command, url)
+ args = append(args, command)
+
+ return exec.Command(shell, args...)
+}