Created
November 3, 2022 16:08
-
-
Save thetutlage/abcbed9e87aba8f3602792e1cb523674 to your computer and use it in GitHub Desktop.
Open current repo in Github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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