Skip to content

Instantly share code, notes, and snippets.

@thetutlage
Created November 3, 2022 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetutlage/abcbed9e87aba8f3602792e1cb523674 to your computer and use it in GitHub Desktop.
Save thetutlage/abcbed9e87aba8f3602792e1cb523674 to your computer and use it in GitHub Desktop.
Open current repo in Github
openRepo() {
githubDomain="https://github.com/"
remoteUrl="$(git config --get remote.origin.url)"
branch="$(git rev-parse --abbrev-ref HEAD)"
# Replace git protocol with github domain
remoteUrl="${remoteUrl/git\@github\.com\:/$githubDomain}"
# Replace `.git` suffix
remoteUrl="${remoteUrl/.git/}"
# Open URL and append current branch name
open "${remoteUrl}/tree/${branch}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment