Skip to content

feat: add URL-based browser configuration#230

Open
vinceyyy wants to merge 2 commits intopaulirish:masterfrom
vinceyyy:feat/url-based-browser-config
Open

feat: add URL-based browser configuration#230
vinceyyy wants to merge 2 commits intopaulirish:masterfrom
vinceyyy:feat/url-based-browser-config

Conversation

@vinceyyy
Copy link
Copy Markdown

Fixes #229

Summary

  • Add open.browser and open.<url>.browser git config support, allowing different browsers for different URL patterns (e.g., Edge for work repos, Safari for personal)
  • Use eval for the browser command to properly handle quoted arguments like open -a 'Microsoft Edge'
  • Reuses the existing getConfig / --get-urlmatch mechanism — only 3 lines added to the script

Example URLs being parsed

# With: git config "open.https://github.com/company-org.browser" "open -a 'Microsoft Edge'"
# Repo: git@github.com:company-org/repo.git
# Opens in: Microsoft Edge

# With: git config open.browser "open -a Safari"
# Repo: git@github.com:personal/repo.git
# Opens in: Safari (default fallback)

Test plan

  • Default browser via open.browser config
  • URL-specific browser via open.<url>.browser config
  • URL-specific config overrides default config
  • Non-matching URL falls back to default browser config
  • Quoted arguments in browser command (e.g., 'Microsoft Edge')
  • BROWSER env var still takes priority over all config
  • All 73 existing + new tests pass

Vincent Yan and others added 2 commits February 14, 2026 17:14
Allow configuring which browser to use via git config, with
URL-specific matching. This enables opening different repos
in different browsers (e.g., work repos in Edge, personal in Safari).

Usage:
  git config --global open.browser "open -a Safari"
  git config --global "open.https://github.com/org.browser" "open -a 'Microsoft Edge'"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Browser commands like `open -a 'Microsoft Edge'` need eval so
quotes inside the variable are interpreted as shell syntax,
not literal characters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configuring browser per URL pattern via git config

1 participant