Open in Browser v2

A VS Code extension that opens files and directories in your browser or git provider's web interface (GitHub, GitLab, Bitbucket).
Published as v2 on VSCode Marketplace and Open VSX Registry.
Quick Start
- Open any file in VS Code
- Press
Alt+B to open in browser
- For git-tracked files: opens in GitHub/GitLab/Bitbucket
- For local files: opens as
file:// URL
Commands
Open in Editor
Shortcut: Shift+Alt+E (editor must be focused)
Opens a file path from the text at the cursor in VS Code. Useful when a comment, log line, or error message contains a path you want to jump to.
- Detects paths under the cursor, including paths in quotes or backticks
- Resolves relative paths against workspace folders, the current file's directory, and ancestor directories (so project-root paths work from nested docs)
- Supports absolute paths and
~/ home paths
- Optional line position:
src/foo.ts:42, src/foo.ts:42:5, src/foo.ts:42:, src/foo.ts:42:5:, src/foo.ts#L42, or location-first 42:5:src/foo.ts
Example:
// see src/util.ts for details
^ cursor here → opens src/util.ts
error in ../config/app.toml:10
^ opens app.toml at line 10
foo/bar/baz.txt:123:
^ opens baz.txt at line 123
foo/bar/baz.txt:123:10
^ opens baz.txt at line 123, column 10
"29:31:foo/bar.txt"
^ cursor here → opens foo/bar.txt at line 29, column 31
# in foo/README.md:
`bar/script.sh:123`
^ cursor here → opens {project}/bar/script.sh at line 123
Open In Default Browser
Shortcut: Alt+B
Opens the current file or directory in your default browser.
- Files in git repos: Opens in GitHub/GitLab/Bitbucket at the current line
- Local files: Opens as
file:// URL
- Terminal: Opens terminal's current directory (when terminal is focused)
- Line numbers: Automatically includes cursor position or selection
Example:
file.ts (cursor at line 42)
→ https://github.com/user/repo/blob/main/file.ts#L42
file.ts (lines 10-20 selected)
→ https://github.com/user/repo/blob/main/file.ts#L10-L20
Open In Other Browser
Choose from a list of installed browsers (Chrome, Firefox, Safari, Edge, Brave, etc.).
Open Commit Under Cursor
Shortcut: Shift+Alt+G
Opens the git commit that last modified the line under the cursor. Links directly to the file diff with the line highlighted.
Example:
Cursor at line 22
→ https://github.com/user/repo/commit/abc123#diff-xyz...L22
Copy Path Under Cursor
Shortcut: Shift+Alt+K
Copies the open file's path and cursor position to the clipboard.
- Format:
path:line:column (1-based line/column)
- Path: Relative to the workspace folder when the file is in the workspace; absolute otherwise
Example:
Editing src/browserConfig.ts at line 123, column 10
→ src/browserConfig.ts:123:10
Copy Remote URL
Shortcut: Shift+Alt+C
Copies the URL to clipboard instead of opening it. Works with all features (git URLs, line numbers, directories).
Open Compare URL
Shortcut: Shift+Alt+M
Opens the branch comparison page on your git provider (compares current branch with base branch).
Example:
Current branch: feature/new-feature
Base branch: main
→ https://github.com/user/repo/compare/main...feature/new-feature
Configuration (optional):
{
"open-in-browser.defaultBaseBranch": "main"
}
Open PR List
Shortcut: Shift+Alt+P
Opens the pull request (or merge request) list for the current git repository.
Example:
→ https://github.com/user/repo/pulls
→ https://gitlab.com/group/project/-/merge_requests
Open Ticket In Browser
Shortcut: Shift+Alt+J
Opens a ticket in your issue tracker (Jira, Linear, GitHub Issues, etc.).
The command resolves tickets in two steps:
- Cursor word — if the cursor is on a ticket-like word in the editor, that word is matched against your configured
ticket_pattern and opened. No git repository is required; this works in any file (notes, scratch buffers, files outside a repo, etc.). Works from the context menu, keyboard shortcut, or command palette.
- Branch fallback — only when there is no cursor word, the current git branch name is checked. This step requires a git repository.
If a cursor word is found but does not match any provider pattern, the command stops with an error and does not fall back to the branch.
Examples:
Cursor on PROJ-1234 in a comment (any file, no git needed)
→ https://your-company.atlassian.net/browse/PROJ-1234
Cursor on [#456](https://github.com/f34nk/vscode-extensions-open-in-browser-v2/issues/456) in notes.txt outside any repository
→ https://github.com/user/repo/issues/456
Branch: feature/XY-1234-add-validation (no cursor word)
→ https://your-company.atlassian.net/browse/XY-1234
Setup:
Create .cursor/open-in-browser-tickets.toml:
[ticket_provider.JIRA]
name = "Jira"
ticket_pattern = "([A-Z]{2,5}-[0-9]{1,6})"
ticket_url_template = "https://company.atlassian.net/browse/${ticket_id}"
priority = 1
# Optional: GitHub-style issue numbers (with or without #)
[ticket_provider.GITHUB]
name = "GitHub Issues"
ticket_pattern = "[#]?(\\d+)"
ticket_url_template = "https://github.com/user/repo/issues/${ticket_id}"
priority = 2
Set config path in settings:
{
"open-in-browser.ticketProviderConfigPath": ".cursor/open-in-browser-tickets.toml"
}
Or run command: "Generate Ticket Provider Config Template"
Generate Provider Config Template
Creates a .cursor/open-in-browser-providers.toml file with examples for customizing git providers.
Reload Provider Config
Reloads git provider TOML configuration files without restarting VS Code.
Show Detected Provider
Shows which git provider was detected for the current repository (useful for debugging).
Generate Ticket Provider Config Template
Creates a .cursor/open-in-browser-tickets.toml file with examples for customizing ticket providers (Jira, Linear, GitHub Issues, etc.).
Reload Ticket Provider Config
Reloads ticket provider TOML configuration files without restarting VS Code.
Configuration
Basic Settings
{
// Default browser (leave empty for system default)
"open-in-browser.default": "firefox",
// Enable git provider URLs
"open-in-browser.preferGitUrl": true,
// Include line numbers in URLs
"open-in-browser.includeLineNumbers": true,
// Path to ticket provider config TOML file
"open-in-browser.ticketProviderConfigPath": ".cursor/open-in-browser-tickets.toml",
// Default base branch for comparisons
"open-in-browser.defaultBaseBranch": "main"
}
Custom Git Providers
Add support for private GitHub Enterprise, GitLab, or Bitbucket instances.
Step 1: Create a TOML config file
Create .cursor/open-in-browser-providers.toml in your workspace, or run command "Generate Provider Config Template".
Step 2: Configure the setting
{
"open-in-browser.providerConfigPaths": [
".cursor/open-in-browser-providers.toml"
]
}
Step 3: Define your provider
Example: GitHub Enterprise
[provider.GITHUB_ENTERPRISE]
name = "Company GitHub"
remote_url_pattern = "^git@github\\.your-company\\.com:(.+)/(.+)\\.git$"
file_url_template = "https://github.your-company.com/${owner}/${repo}/blob/${branch}/${relative_path}"
directory_url_template = "https://github.your-company.com/${owner}/${repo}/tree/${branch}/${relative_path}"
line_fragment_single = "#L${line_start}"
line_fragment_range = "#L${line_start}-L${line_end}"
pr_list_url_template = "https://github.your-company.com/${owner}/${repo}/pulls"
compare_url_template = "https://github.your-company.com/${owner}/${repo}/compare/${base_branch}...${current_branch}"
commit_url_template = "https://github.your-company.com/${owner}/${repo}/commit/${commit_sha}"
commit_file_url_template = "https://github.your-company.com/${owner}/${repo}/commit/${commit_sha}#diff-${commit_file_hash}L${commit_line_number}"
[provider.GITHUB_ENTERPRISE.captures]
owner = 1
repo = 2
Template Variables
Available variables for URL templates:
| Variable |
Description |
${owner}, ${repo}, ${group}, ${project} |
Repository identifiers from regex captures |
${branch} |
Current branch name |
${relative_path} |
File/directory path relative to repo root |
${line_start}, ${line_end} |
Line numbers for selections |
${base_branch}, ${current_branch} |
Branches for comparisons |
${commit_sha} |
Git commit SHA |
${commit_file_hash} |
File path hash for commit URLs |
${commit_line_number} |
Line number in commit diff |
Config File Locations
Multiple config files are merged (later overrides earlier):
- Built-in defaults (GitHub, GitLab, Bitbucket)
- User home:
~/.config/vscode-open-in-browser/providers.toml
- Workspace:
.cursor/open-in-browser-providers.toml
- Custom paths (from
providerConfigPaths setting)
Example: Multiple config files
{
"open-in-browser.providerConfigPaths": [
"~/.config/company/git-providers.toml",
".cursor/project-specific.toml"
]
}
Built-in Git Providers
- GitHub (github.com) - SSH and HTTPS
- GitLab (gitlab.com) - SSH and HTTPS
- Bitbucket/Stash (Atlassian) - SSH
All providers support: files, directories, line numbers, PR lists, branch comparisons, and commit links.
Terminal Support
Works with integrated terminal! When terminal is focused:
- Press
Alt+B to open terminal's current working directory
- Supports git repositories (opens in web interface)
- Supports local directories (opens as
file:// URL)
- Works on macOS, Linux, and Windows
All Configuration Options
{
"open-in-browser.default": "",
"open-in-browser.preferGitUrl": true,
"open-in-browser.includeLineNumbers": true,
"open-in-browser.enableTerminalSupport": true,
"open-in-browser.terminalFallbackToWorkspace": true,
"open-in-browser.gitTimeout": 5000,
"open-in-browser.ticketProviderConfigPath": "",
"open-in-browser.defaultBaseBranch": "main",
"open-in-browser.providerConfigPaths": [],
"open-in-browser.useBuiltinProviders": true,
"open-in-browser.commitUrlIncludeFile": true
}
Troubleshooting
Viewing logs
When a command fails, click Show Log in the error notification, or open View → Output and select Open in Browser.
Log entries include:
- Timestamp and severity (
ERROR / WARN)
- Context (which command or module failed, e.g.
openTicketInBrowser, openUrl)
- Details such as branch name, cursor word, URL, or config path
- Stack traces for unexpected exceptions
Separate output channels remain available for verbose config loading:
- Open in Browser - Providers (git provider TOML)
- Open in Browser - Browsers (browser TOML)
- Open in Browser - Tickets (ticket provider TOML)
Custom provider not working
Run command: "Show Detected Provider" to see which provider matched.
Check:
- TOML syntax is valid
- Regex pattern matches your git remote URL (test with
git remote -v)
- Escape special characters:
\\. for ., \\d for \d
Terminal directory detection not working
- Click in the terminal first to focus it
- Wait a second after opening terminal for shell to initialize
- Check
open-in-browser.enableTerminalSupport is enabled
Ticket not found
The command checks the word under the cursor first (no git required), then the current git branch name only when there is no cursor word.
- Place the cursor inside a ticket ID in the editor (e.g.
PROJ-1234 or #456) — works in any file, including files outside a git repository
- For branch-based lookup, use a branch name that contains a matching ticket ID and ensure the file or terminal path is inside a git repository
- When using the editor context menu, the cursor position in that file is used even if focus moved to the menu (including in Cursor when chat/composer holds focus)
- Verify
ticket_pattern in .cursor/open-in-browser-tickets.toml matches your ticket format (Jira PROJ-1234, Linear LIN-99, GitHub #456 or 456, etc.)
- If a cursor word is found but does not match, you get
No ticket found in "..." at cursor. — adjust your pattern or place the cursor on the full ticket ID
- “Not in a git repository” appears only for branch fallback when there was no cursor word to check
- Run command: "Generate Ticket Provider Config Template" to create example config
- If it still fails, check Open in Browser in the Output panel — the log shows the cursor word and/or branch name that were tried
Open in Editor not finding a path
- Place the cursor inside the path text (not on whitespace beside it)
- Path must look like a file path (include
/ or a file extension)
- HTTP URLs are ignored
- Only files are opened; directories show an error
Development
make # clean, install, compile, and run tests
npm test # run unit tests
npm run compile
Requirements
- VS Code 1.30.0+ (including Cursor)
- Git (for git-aware features)
License
LGPL-2.1-or-later
Credits
Original by techer. Enhanced with git-aware features, line numbers, terminal support, customizable providers, and open-path-at-cursor navigation.
Install from Marketplace | GitHub | Changelog