Fleeting thoughts

Punchcard - punch in, punch out

by Johannes Martinsson

Have you seen the “punchcard” graphics on any Github project? I wanted that, but in my terminal emulator.

I wrote a Go program that reads dates on stdin and prints one of these nice 2D histograms. Then to get the git repository view I use git log to pipe commit dates to go-punchcard.

Separating the presentation from the data source in this way makes it easy to also use go-punchcard for visualizing my coffee consumption.

git punchcard showing commit times.

git punchcard showing commit times.

go-punchcard showing coffee times.

go-punchcard showing coffee times.

Installing

Given that you have the Go distribution installed and ~/bin on your $PATH, run:

go get antiklimax.se/go-punchcard
echo 'git log --pretty=format:%cd | go-punchcard' > ~/bin/git-punchcard
chmod +x ~/bin/git-punchcard

Usage

The go-punchcard program isn’t really limited to being used together with git. It expects to find one or two dates on each line of standard input. The expected time format can be tweaked by usage of the -layout flag.