Skip to content

Add 'copy branch URL to clipboard' keybinding#5399

Open
Mentigen wants to merge 2 commits intojesseduffield:masterfrom
Mentigen:copy-branch-url-to-clipboard
Open

Add 'copy branch URL to clipboard' keybinding#5399
Mentigen wants to merge 2 commits intojesseduffield:masterfrom
Mentigen:copy-branch-url-to-clipboard

Conversation

@Mentigen
Copy link

PR Description

Adds a keybinding (default: y) in the branches panel to copy the branch's web URL to the clipboard. This is the URL of the branch page on the hosting service, as opposed to the pull request URL (already available via <c-y>).

Closes #1959

Supported hosting services:

Service Branch URL format
GitHub /tree/<branch>
GitLab /-/tree/<branch>
Bitbucket /branch/<branch>
Azure DevOps ?version=GB<branch>
Bitbucket Server /browse?at=<branch>
Gitea /src/branch/<branch>
Codeberg /src/branch/<branch>

Branch names with special characters are URL-encoded (same as existing PR URL behaviour).

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (TestGetBranchURL in hosting_service_test.go)
  • Text is internationalised (added CopyBranchURL and BranchURLCopiedToClipboard to english.go)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (keybinding config reloads automatically)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Adds a keybinding (default: 'y') in the branches panel to copy the
branch's URL on the hosting service to the clipboard.

Each supported hosting service has a dedicated URL template:
- GitHub:           /tree/<branch>
- GitLab:           /-/tree/<branch>
- Bitbucket:        /branch/<branch>
- Azure DevOps:     ?version=GB<branch>
- Bitbucket Server: /browse?at=<branch>
- Gitea/Codeberg:   /src/branch/<branch>

Closes jesseduffield#1959
@Mentigen Mentigen force-pushed the copy-branch-url-to-clipboard branch from 8468664 to c2faca1 Compare March 20, 2026 21:30
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.

Copy branch URL to clipboard

1 participant