-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override browser? #41
Comments
See #14 (comment) for why this is infeasible, since there is not a BROWSER spec and different tools implement reading this environment variable differently in regard to argument passing, quoting, and shell expansion. |
I think infeasible is strong. A common sense implementation here could be well worth it. It's not clear to me why one would need a priority list of browsers or even Thus I propose we interpret For example if sh -c 'run this command --this-is-a-flag "$1"' -- 'https://github.com/pkg/browser/issues/41' The other nice thing about |
Here's what I'm using: func OpenURL(ctx context.Context, url string) error {
browserEnv := os.Getenv("BROWSER")
if browserEnv != "" {
browserSh := fmt.Sprintf("%s '$1'", browserEnv)
cmd := exec.CommandContext(ctx, "sh", "-c", browserSh, "--", url)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to run %v (out: %q): %w", cmd.Args, out, err)
}
return nil
}
return browser.OpenURL(url)
} It implements the above proposal. |
@mislav I think infeasible is too strong here. There's clearly appetite for this, and technical solutions have been proposed that seem like a sensible first approximation to a 'low(est?) common denominator' (e.g. directly above). I'd think there are a few approaches here that could resolve the desire for this feature (in my personal decreasing preference order):
|
On many linux systems, the
BROWSER
environment variable allows users to specify their default browser, much like theEDITOR
orPAGER
environment variables.Would you be open to a PR that adds support for a browser parameter and/or environment variable? I'm happy to contribute Windows and MacOS support for these.
The text was updated successfully, but these errors were encountered: