Made this alias to open github urls in my browser. I’m using the python webbrowser module to launch the default browser.

`[alias] hub = !git remote -v|sed -e 's@.*git:\\(.*\\).git.*@http:\\1@'|xargs python -c "'import sys,webbrowser as w;w.open(sys.argv[1]);'"`

Turns out I missed some cases with my previous sedexpression, this one is better.

[alias]   
    #os x (faster):
    hub = !git remote -v|sed "'s|.*git[:@]\\(.*\\).git.*|http://\\1|;s|m:|m/|'"|uniq|xargs open

    #platform independent (slower, but it works on linux too):   
    hub = !git remote -v|sed "'s|.*git[:@]\\(.*\\).git.*|http://\\1|;s|m:|m/|'"|uniq|xargs python -c "'import sys,webbrowser as w;w.open(sys.argv[1]);'"

If you want to launch slightly faster you can avoid launching a python process by calling into your browser directly. Here is a firefox example, other browsers should be similar.

[alias]
    hub = !git remote -v|sed "'s|.*git[:@]\\(.*\\).git.*|http://\\1|;s|m:|m/|'"|uniq|

While we are the subject of git aliases here is an gitx/gitk/gitwhatever-ish view using just git log

[alias]
    lg = log --pretty=oneline --all --graph --abbrev-commit --decorate


blog comments powered by Disqus

Published

29 March 2011

Tags