Skip to content

Instantly share code, notes, and snippets.

@brock
Created February 26, 2012 16:59
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 brock/1917716 to your computer and use it in GitHub Desktop.
Save brock/1917716 to your computer and use it in GitHub Desktop.
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