Skip to content

Instantly share code, notes, and snippets.

@LeaVerou
Created June 24, 2026 23:27
Show Gist options
  • Select an option

  • Save LeaVerou/d991f76a9a45dd90a3fcf5261e13006c to your computer and use it in GitHub Desktop.

Select an option

Save LeaVerou/d991f76a9a45dd90a3fcf5261e13006c to your computer and use it in GitHub Desktop.
Bookmarklet to open GitHub URL locally
javascript:(() => {
const BASE = '/Users/lea/code';
const g = new URLPattern(
'https://github.com/:owner/:repo{/:kind(blob|tree|edit)}?{/:ref}?{/:file(.*)}?'
).exec(location)?.pathname.groups;
if (!g) return alert('Not a GitHub repo URL');
const line = location.hash.match(/^#L(\d+)/)?.[1] ?? '';
location.href =
`vscode://file${BASE}/${g.repo}${g.file ? `/${g.file}` : ''}${line && `:${line}`}`;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment