Skip to content

Instantly share code, notes, and snippets.

@whobutsb
Created April 18, 2017 17:51
Show Gist options
  • 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 != [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