Skip to content

Instantly share code, notes, and snippets.

@anthonybruno
Last active December 17, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybruno/5637371 to your computer and use it in GitHub Desktop.
Save anthonybruno/5637371 to your computer and use it in GitHub Desktop.
Terminal command to open current github repo in browser
# Opens the github page for the current git repository in your browser
# git@github.com:jasonneylon/dotfiles.git
# https://github.com/jasonneylon/dotfiles/
function gh() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
fi
giturl=${giturl/git\@github\.com\:/https://github.com/}
giturl=${giturl/\.git//}
echo $giturl
open $giturl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment