Last active
December 14, 2015 04:28
-
-
Save davidosomething/5027910 to your computer and use it in GitHub Desktop.
Open current repo's github page if it has one.
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
# Depends on AWK, SED, and OSX's open command. | |
function github() { | |
local github_url | |
if ! git remote -v >/dev/null; then | |
return 1 | |
fi | |
# get remotes for fetch | |
github_url="`git remote -v | grep github\.com | grep \(fetch\)$`" | |
if [ -z "$github_url" ]; then | |
echo "A GitHub remote was not found for this repository." | |
return 1 | |
fi | |
# look for origin in remotes, use that if found, otherwise use first result | |
if [ "echo $github_url | grep '^origin' >/dev/null 2>&1" ]; then | |
github_url="`echo $github_url | grep '^origin'`" | |
else | |
github_url="`echo $github_url | head -n1`" | |
fi | |
github_url="`echo $github_url | awk '{ print $2 }' | sed 's/git@github\.com:/http:\/\/github\.com\//g'`" | |
open $github_url | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment