Open Your Github Repo in a Web Browser from the Shell

This assumes that your first remote is a github remote. Put the following in the appropriate bash or zsh initialization script and that you’re on a Mac. You might need to change “open” to whatever will launch a URL in a web browser on a different *nix system.

function gitweb() {
  git remote -v | head -n 1 | awk '{print $2}' | sed 's/.git$//' | sed 's/\/\/\//' | xargs -I {} open {}

%d bloggers like this: