Created
February 26, 2012 16:59
-
-
Save brock/1917716 to your computer and use it in GitHub Desktop.
Open Git Project 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
# GH | |
# by Brock Angelo | |
# for Mac OSX & Unix | |
# https://gist.github.com/1917716 | |
# Description: when you are on the command line and want to open your project in Github, just type "gh". Latest version opens the current branch on github as well. | |
# | |
# SETUP: | |
# 1. Copy this snippet to ~/bin/gh | |
# 2. Make it executable by running: chmod +x ~/bin/gh | |
# 3. From the command line, inside your project, type gh and the browser window will open. | |
BRANCH=$(git branch | grep "*" | awk '{print $2}') | |
git remote -v | grep fetch | sed 's/\(.*github.com\)[:|/]\(.*\).git (fetch)/\2/' | awk -v BRANCH=$BRANCH {'print "https://github.com/" $1 "/tree/" BRANCH'} | xargs open |
updated to check locally rather than querying remotely - saves about a second or two.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to work for projects you don't own