Skip to content

Instantly share code, notes, and snippets.

@benwells
Created April 13, 2016 15:56
Show Gist options
  • Save benwells/44ab7cd2a80278c3ac51f51936f5ea9e to your computer and use it in GitHub Desktop.
Save benwells/44ab7cd2a80278c3ac51f51936f5ea9e to your computer and use it in GitHub Desktop.
Open a Pull Request for current branch from OSX Terminal
# put this function in your .bash_profile or .zshrc to open the github compare screen
# for your current branch. Of course, you must push your branch up remotely first for this to work.
# The function parses your current working branch from the output of git branch
# and opens github in Chrome, right to the compare page for your branch.
#
# Edit myaccountname and myreponame and enter the account and repo of your choice.
#
function openpr () {
ACCOUNT=myaccountname # replace with your account name
REPO=myreponame # replace with your repo name
URL=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/github\.com\/GITHUB_ACCOUNT\/GITHUB_REPO\/compar e\/\1/'`
URL="${URL/GITHUB_ACCOUNT/$ACCOUNT}"
URL="${URL/GITHUB_REPO/$REPO}"
open -a /Applications/Google\ Chrome.app https://$URL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment