Skip to content

Instantly share code, notes, and snippets.

@chr15m
Created August 14, 2017 01:40
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 chr15m/c3f76f97f0feabab2e293424023ddb86 to your computer and use it in GitHub Desktop.
Save chr15m/c3f76f97f0feabab2e293424023ddb86 to your computer and use it in GitHub Desktop.
Open a GitHub pull-request page from the command line
#!/usr/bin/env python
import webbrowser
import subprocess
def git(*args):
return subprocess.check_output(["git"] + list(args))
remote, branch = git("rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}").split("/")
repo = git("config", "--get", "remote." + remote + ".url").split(":").pop().replace(".git", "").strip("\n")
webbrowser.open("https://github.com/%s/tree/%s" % (repo, branch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment