Skip to content

Instantly share code, notes, and snippets.

@jdeeburke jdeeburke/.bashrc
Created Apr 29, 2020

Embed
What would you like to do?
GitHub Helper Shell Commands
# Only tried this on mac, would probably need some adaptation for Linux folks :)
#
# Add this to your .bashrc or .zshrc file and reload terminal for it to take effect
# Output GitHub PR URL for the current git repo
ghpr() {
repo=$(git remote -v | sed -n 's/^origin.*git@github\.com:\(.*\)\.git.*fetch.*/\1/p')
branch=$(git branch --show-current)
echo "https://github.com/$repo/compare/$branch?expand=1"
}
# Open GitHub PR URL in Browser
ghpro() {
url="$(ghpr)"
open $url
}
# Copy GitHub PR URL to clipboard
alias ghprc="ghpr | pbcopy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.