Skip to content

Instantly share code, notes, and snippets.

@jhildensperger
Last active August 29, 2015 14:08
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 jhildensperger/521e9baeff9d545113e8 to your computer and use it in GitHub Desktop.
Save jhildensperger/521e9baeff9d545113e8 to your computer and use it in GitHub Desktop.
Open current branch on github compared to master
# add .open-github-branch.bash to ~/
# add commented code to your ~/.bash_profile
# restart terminal and enjoy!
#
# if [ -f ~/.open-github-branch.bash ]; then
# . ~/.open-github-branch.bash
# fi
#
# alias gpr='__open_github_branch'
#!/bin/bash
__open_github_branch()
{
branch=$(git rev-parse --abbrev-ref HEAD)
remoteUrl=$(git config --get remote.origin.url)
remoteUrl=${remoteUrl/.git/}
if [[ $remoteUrl == *"git@"* ]]
then
remoteUrl=${remoteUrl/://}
remoteUrl=${remoteUrl/git@/https://}
fi
open $remoteUrl/compare/$branch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment