Created
April 18, 2017 17:51
-
-
Save whobutsb/71ec536858957b6010d862f08ccc38f3 to your computer and use it in GitHub Desktop.
Open GitHub repo in bash
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
function Github() { | |
if [ ! -d .git ] ; | |
then echo "ERROR: This isn't a git directory" && return false; | |
fi | |
git_url=`git config --get remote.origin.url` | |
if [[ $git_url != [email protected]:* ]] ; | |
then echo "ERROR: Remote origin is invalid" && return false; | |
fi | |
url=${git_url%.git} | |
if [[ $url == [email protected]:* ]] ; | |
then url=$(echo $url | sed 's,[email protected]:,https://github.com/,g') | |
fi | |
open $url | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment