Skip to content

Utilize 'gh browse' as a cross-platform solution to open a URL in the browser  #7620

@LangLangBart

Description

@LangLangBart

Describe the feature or problem you’d like to solve

Ability to open a specific GitHub URL with gh browse in the default browser, regardless of the operating system.

Possible use case in a bash extensions, e.g. when opening a specific workflow, a comment on an issue, or a pr review by selecting it with fzf.

Additional context

  • current workarounds
#!/usr/bin/env bash
set -euo pipefail

url="https://github.com/cli/cli/pull/4663#pullrequestreview-794795478"

# 1st: case
  case "$(uname -s)" in
    Darwin) open "$url"     ;;
    Linux)  xdg-open "$url" ;;
    *) 		start "$url" ;;
  esac

# 2nd: python
python -m webbrowser "$url"

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussFeature changes that require discussion primarily among the GitHub CLI teamenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions