Created
April 21, 2017 15:50
-
-
Save elpete/c3c8e7634f3bfe7fb6a63b72bf8b3417 to your computer and use it in GitHub Desktop.
Open a github repo from the command line
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
alias github=GitHub | |
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 | |
url="https://github.com/${git_url#[email protected]:}" | |
url=${url%.git} | |
open $url | |
return true; | |
fi | |
if [[ $git_url == https://github* ]] ; then | |
url=${git_url%.git} | |
open $url | |
return true; | |
fi | |
echo "ERROR: Remote origin is invalid" && return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified from https://dev.to/shayde/open-the-github-project-page-of-a-repo-from-terminal