Skip to content

Instantly share code, notes, and snippets.

@brock
Created Feb 26, 2012
Embed
What would you like to do?
Open Git Project in Github
# 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
@brock
Copy link
Author

brock commented Feb 28, 2012

updated to work for projects you don't own

@brock
Copy link
Author

brock commented Mar 28, 2012

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