(The $ after the = is an example of using Bash’s ANSI C quoting mechanism.)
(CSH single quote escaping is even more convoluted…)
Basically, we grab the remote URL from with
git config, strip out
the repo path and slap https://github.com/ in front of it with
and then use
open to feed the new URL the default web browser.
This makes a couple presumptions:
- You are in a Git repo.
- You are using SSH style URLs.
- open is OS X specific. On Linux you’d want xdg-open or gnome-open, on Windows, start, under Cygwin, cygstart.
Making it smarter is left as an exercise to the reader.