Today, I want to present a frequently used command line tool of mine: git home. It makes working with repositories on web-based hosters faster, so I thought I would share this delightful everyday helper with the world.

What does it do? When called, git home simply opens the homepage of the repository your are currently in. It does so by taking the origin url and opening that in your default web browser using macOS’s open command. You can optionally specify the name of the remote, if you want to go somewhere else. There are straight-forward alternatives for opening the url on other systems.

Here is the source:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/bin/bash
# Opens the website for the current origin in the browser

set -euo pipefail

REMOTE=${1:-"origin"}

git remote get-url "$REMOTE" \
  | sed -n "s/.*@\(.*\)\.git/\1/p" \
  | tr ':' '/' \
  | xargs -I "{}" open "https://{}"

Create a file called git-home anywhere in your $PATH. Afterwards, you can call it using git home.

According to git history, git-home made it into my dotfiles repository as git-hub more than eight years ago. I wrote it to quickly open the repository on the web for looking at issues, pipeline statuses, and similar tasks. Apart from minor improvements, the script has stayed the same since its inception, and has proven to be a delight in what it does. I hope it will be for you as well.