Skip to content

Instantly share code, notes, and snippets.



Created Apr 29, 2020
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 "$repo/compare/$branch?expand=1"
# Open GitHub PR URL in Browser
ghpro() {
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