Skip to content

Instantly share code, notes, and snippets.

@whobutsb
Created April 18, 2017 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save whobutsb/71ec536858957b6010d862f08ccc38f3 to your computer and use it in GitHub Desktop.
Save whobutsb/71ec536858957b6010d862f08ccc38f3 to your computer and use it in GitHub Desktop.
Open GitHub repo in bash
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 echo "ERROR: Remote origin is invalid" && return false;
fi
url=${git_url%.git}
if [[ $url == git@github.com:* ]] ;
then url=$(echo $url | sed 's,git@github.com:,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