Skip to content

Instantly share code, notes, and snippets.

@tcrayford
Created February 21, 2012 13:34
Show Gist options
  • Save tcrayford/1876606 to your computer and use it in GitHub Desktop.
Save tcrayford/1876606 to your computer and use it in GitHub Desktop.
#!/bin/bash
# assuming `origin (push)` is a github url,
# this opens the current branch on github's site,
# ready for a pull request
# only works on macs right now (it uses `open`)
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -e 's/)//' -e 's/(//'
}
function open_branch {
open "https://`repo_root`/tree/`parse_git_branch`"
}
function repo_root {
git remote -v | grep "origin.*push" | cut -f 2 -d '@' | cut -f 1 -d ' ' | sed -e 's/\.git//' -e 's/:/\//'
}
open_branch
@joelplane
Copy link

Nice.

Could do something like this to work on linux too
OPEN=which xdg-open || which open
and call $OPEN instead of open. (or just simply replace open with xdg-open)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment