Skip to content

Instantly share code, notes, and snippets.

@jdeeburke
Created April 29, 2020 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeeburke/32a92fbd68a05b6d59d9748ea07f9230 to your computer and use it in GitHub Desktop.
Save jdeeburke/32a92fbd68a05b6d59d9748ea07f9230 to your computer and use it in GitHub Desktop.
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