Open GitHub PR URL by number from macOS

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/.*\(.*\).git.*$/https:\/\/\/\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 ( URLs instead of https.

Leave a Reply

%d bloggers like this: