Sometimes you want to be able to open a GitHub PR URL in your default browser in macOS with just the number of the PR. This can be accomplished with the following function in zsh
, which can be added to your .zshrc
:
function seepr() {
open `git remote -v | grep push | sed 's/.*github.com:\(.*\).git.*$/https:\/\/github.com\/\1\/pull\//'`$1
}
Some caveats to using this code:
- This assumes that you’re in a local copy of the repository of the PR you want to open up in the browser.
- You’re using SSH (
git@github.com:org/repo.git
) URLs instead ofhttps
.