Skip to content

Instantly share code, notes, and snippets.

@elpete
Created April 21, 2017 15:50
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 elpete/c3c8e7634f3bfe7fb6a63b72bf8b3417 to your computer and use it in GitHub Desktop.
Save elpete/c3c8e7634f3bfe7fb6a63b72bf8b3417 to your computer and use it in GitHub Desktop.
Open a github repo from the command line
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 == git@github.com* ]] ; then
url="https://github.com/${git_url#git@github.com:}"
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;
}
@elpete
Copy link
Author

elpete commented Apr 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment