Created
February 21, 2012 13:34
-
-
Save tcrayford/1876606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)