Skip to content

I can't copy a GitHub permalink to the current line, or open it on GitHub #604

Open

Description

@a-team-app

Opportunity

When I'm reading or reviewing code in TuiCode and want to point someone at a line, in a PR comment, a chat or an issue, I have no way to hand it over. I leave TuiCode, find the file on GitHub in a browser, scroll to the line and copy the URL, or run gh browse path:line in another shell. The same goes the other way: when I want to see the line on GitHub (its blame, the PR that touched it, to share a screen), there's no way to get there from where I am.

The stakeholder hit this while trying out #591 on PR #595 (comment): "I wanted to either copy a permalink to a line of code or open that line of code in GitHub... I can't do either of those at the moment."

Every editor the vision learns from has it: VS Code's Share › Copy GitHub Permalink and Open on GitHub, JetBrains' Open In › GitHub and Copy Link to GitHub, and Zed's Copy permalink to line / Open permalink to line. Reviewing PRs and sharing what you've read is most of the day for the vision's user.

Options considered

  1. Do nothing. Blame (gb) shows the commit, and gh browse exists in a shell. Free, but it's exactly the trip to another tool the vision says to remove, and over SSH the browser isn't even on the same machine.
  2. Copy the path and line only (src/Foo.cs:42). Simple and host-agnostic, and handy for pasting into an AI chat, but it isn't a link: nobody can click it, and it rots as soon as the file changes.
  3. Ask gh browse for the URL (gh browse --commit <sha> -n path:L). Reuses gh, which the Review tab already uses, and handles GitHub Enterprise. But it fails when gh isn't installed or signed in, and spawns a process that talks to the network for something we can work out from git remote ourselves.
  4. Two commands that build the link from the repo's remote and the current commit (chosen). Copy permalink puts it on the clipboard; Open on GitHub opens it in the browser. Nothing new to install, it works offline, and it's built from git alone, so it's quick and testable.

I chose 4: it's what the other editors do, and it needs no more than git, which TuiCode already relies on.

Proposal

Two new commands on a file tab, in the Diff menu next to Git blame, in F1, the palette and the leader:

  • Copy permalink (cp): copies https://github.com/<owner>/<repo>/blob/<commit>/<path>#L42 for the cursor's line, or #L42-L48 when lines are selected. It goes through the editor's own copy, so it reaches your machine over SSH too (OSC 52). The status bar says Copied permalink to line 42.
  • Open on GitHub (oog): opens the same link in the browser, as Follow link does. Over SSH it copies it instead and says so, also as Follow link does.

The commit is HEAD's, so the link keeps pointing at the same code after the branch moves on. Where that would mislead, the status bar says so:

  • HEAD isn't on the remote yet: Copy permalink still copies and says Copied, but 4a91c0e isn't pushed yet: the link works once it is. Open on GitHub doesn't open a page that isn't there: 4a91c0e isn't pushed yet: push it to open this line on GitHub.
  • The file has changes since HEAD (unsaved or uncommitted): it still works, and adds the file has changed since 4a91c0e, so line 42 there may not be this line.
  • Not a git repo, an untracked file, or no GitHub remote: nothing is copied or opened, and the status bar says why, the way blame does.

Mockup

The Diff menu (Alt+D):

┌ Diff ───────────────────────────────┐
│ Compare to saved                    │
│ Compare to revision                 │
│ Compare to other file               │
├─────────────────────────────────────┤
│ Next change              Alt+↓      │
│ Previous change          Alt+↑      │
│ Go to change line                   │
├─────────────────────────────────────┤
│ Revert change                       │
│ Revert all changes                  │
├─────────────────────────────────────┤
│ Git blame                Ctrl+G B   │
│ Copy perMalink                      │
│ Open on GitHub                      │
└─────────────────────────────────────┘

(M and H are the items' letters, underlined.)

The status bar afterwards:

Copied permalink to lines 42–48                 Ln 48, Col 1   Press F1 for help
Copied, but 4a91c0e isn't pushed yet: the link works once it is   Ln 42, Col 9   Press F1 for help

Scope

In

  • Copy permalink and Open on GitHub, Editor scope, on file tabs, with mnemonics, menu items and F1 rows.
  • github.com remotes in their SSH (git@github.com:o/r.git, ssh://git@github.com/o/r) and HTTPS forms, and GitHub Enterprise hosts, which use the same URL shape.
  • A selection of several lines; with several carets, the primary one.

Out

  • Diff tabs. On a review, Enter already opens the file tab beside the diff, and that's where these work. Easy to add later if it's missed.
  • GitLab, Bitbucket and Azure DevOps links. Their URL shapes differ; the status bar says the remote isn't GitHub.
  • A Copy relative path command, or a branch (not commit) link like VS Code's Copy GitHub Head Link.
  • Pushing for you when HEAD isn't pushed.
  • Default keybindings. Both are a mnemonic away, and can be bound in Settings like any command.

Delivery

One PR.

Assumed

  • The remote is the current branch's upstream's, else origin, else the only one. That's the remote you push to, which is where the commit will be.
  • "On the remote" means some remote-tracking branch contains HEAD (git branch -r --contains), read from what git already knows, with no fetch. A stale view errs towards warning, which is harmless.
  • Any host that isn't GitLab, Bitbucket or Azure DevOps is treated as GitHub or GitHub Enterprise. Enterprise hosts can have any name, so there's no list to check against; a wrong guess gives a link that 404s rather than a wrong page.
  • Copying still happens when HEAD isn't pushed; opening doesn't. You often copy a link to paste after you push, but opening a page that isn't there helps nobody.
  • Diff menu, beside Git blame. It's where the other git-per-line command lives.
  • Mnemonics cp and oog, the labels' initials, as the mnemonic rule says. Neither clashes with or prefixes an existing one.

Original idea

There's no way to share or open the line under the cursor on GitHub. I'd like to either copy a permalink to the current line (or selection), or open that line in the browser on GitHub, built from the repo's remote and the current commit.

Follow-up from #591

Activity

  1. added
    rank:mediumThe a-team Lead recommends Medium; your Priority still decides
    on Oct 23, 2026
  2. a-team-app commented on Oct 23, 2026

    @a-team-app
    ContributorAuthor

    Recommended: Medium · theme 2 (Seeing change), small · sharing a line in a PR or chat is a daily thing; built from the remote and HEAD with no new UI beyond a command

  3. added
    pitchAn a-team pitch: Lead shapes it, reviewer approves it
    theme: Daily-driver gapsThe vision theme the a-team Lead says this pitch serves
    on Oct 23, 2026
  4. a-team-app commented on Oct 23, 2026

    @a-team-app
    ContributorAuthor

    Took this next on my Medium recommendation, which put it ahead of the other High ideas. Drafted as two commands, Copy permalink (cp) and Open on GitHub (oog), built from the remote and HEAD; it waits in Exploring for a slot in Pitched.

  5. a-team-app commented on Oct 24, 2026

    @a-team-app
    ContributorAuthor

    This is in front of you now. I checked it against today's main and didn't need to change anything: the Diff menu still has M and H free for the two items, and cp and oog still clash with no other mnemonic. There's nothing in it to answer, so it's yours to approve, change or shelve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pitchAn a-team pitch: Lead shapes it, reviewer approves itrank:mediumThe a-team Lead recommends Medium; your Priority still decidestheme: Daily-driver gapsThe vision theme the a-team Lead says this pitch serves

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions