Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Created February 8, 2022 02:58
Show Gist options
  • Save scottsauber/74a18049f3df9e7778113b8c052b27a1 to your computer and use it in GitHub Desktop.
Save scottsauber/74a18049f3df9e7778113b8c052b27a1 to your computer and use it in GitHub Desktop.
# create new PR and open it
function pr() {
github_url=`git remote -v | awk '/fetch/{print $2}' | sed -Ee 's#(git@|git://)#https://#' -e 's@com:@com/@' -e 's%\.git$%%' | awk '/github/'`;
branch_name=`git symbolic-ref HEAD | cut -d"/" -f 3,4`;
main_branch=`git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4`
open_or_start='open'
uname=$(uname)
if [[ "$uname" == CYGWIN* || "$uname" == MINGW* ]] ; then
open_or_start='start'
fi
pr_url=$github_url"/compare/$main_branch..."$branch_name
$open_or_start $pr_url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment