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