Skip to content

Instantly share code, notes, and snippets.

@matthewkturner
Last active March 30, 2019 02:52
Show Gist options
  • Save matthewkturner/db7cbafd5cb76f67bf1ae33485818ac1 to your computer and use it in GitHub Desktop.
Save matthewkturner/db7cbafd5cb76f67bf1ae33485818ac1 to your computer and use it in GitHub Desktop.
open pull request
github_org='narvar'
github_repo=${PWD##*/}
git_branch() {
local git_status="$(git status 2> /dev/null)"
local on_branch="On branch ([^${IFS}]*)"
local on_commit="HEAD detached at ([^${IFS}]*)"
if [[ $git_status =~ $on_branch ]]; then
local branch=${BASH_REMATCH[1]}
echo "$branch"
elif [[ $git_status =~ $on_commit ]]; then
local commit=${BASH_REMATCH[1]}
echo "$commit"
fi
}
open_pull_request() {
open -a Google\ Chrome https://github.com/$github_org/${PWD##*/}/compare/master...$(git_branch)?w=0
}
alias pr=open_pull_request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment