Skip to content

Instantly share code, notes, and snippets.

@alexng353
Last active February 21, 2026 04:02
Show Gist options
  • Select an option

  • Save alexng353/807594a98ae2e72ce33f1220fa0c0704 to your computer and use it in GitHub Desktop.

Select an option

Save alexng353/807594a98ae2e72ce33f1220fa0c0704 to your computer and use it in GitHub Desktop.
commit histogram

Commitstogram

Just put this file in your $PATH and commitstogram 26 your_name someone_else (since 26 weeks ago, compare you to someone else, or just commitstogram 26 your_name for you vs. everyone else.)

for lazy people: (assuming you have ~/.local/bin/ in your $PATH)

curl -fsSL https://gist.githubusercontent.com/alexng353/807594a98ae2e72ce33f1220fa0c0704/raw/279d3479076252ba27ff72ca7d0dce6cce21dc0f/commitstogram -o ~/.local/bin/commitstogram && chmod +x ~/.local/bin/commitstogram

Works on Linux (and probably MacOS) --- No idea if it works on Windows. Put it in Claude and get Claude to write a windows-friendly version.

Pics (or it didn't happen, right?)

image
#!/usr/bin/env bash
set -euo pipefail
weeks="${1:-26}"
author1="${2:-}"
author2="${3:-}"
width=50
red=$'\033[91m'
blue=$'\033[94m'
white=$'\033[37m'
reset=$'\033[0m'
git log --since="$weeks weeks ago" --format="%ad|%aN|%aE" --date=format:"%G-W%V" \
| gawk -F'|' \
-v a1="$author1" -v a2="$author2" -v width="$width" \
-v red="$red" -v blue="$blue" -v white="$white" -v reset="$reset" \
'{
week = $1
author = tolower($2 " " $3)
total[week]++
if (a1 != "" && author ~ tolower(a1)) c1[week]++
if (a2 != "" && author ~ tolower(a2)) c2[week]++
}
END {
max = 0
for (w in total) if (total[w] > max) max = total[w]
if (max == 0) { print "No commits."; exit }
n = asorti(total, sorted)
for (i = 1; i <= n; i++) {
w = sorted[i]
t = total[w] + 0
v1 = c1[w] + 0
v2 = c2[w] + 0
e1 = int(v1 * width / max + 0.5)
e2 = int((v1 + v2) * width / max + 0.5)
e3 = int(t * width / max + 0.5)
bar = ""
if (e1 > 0) { bar = bar red; for (j = 0; j < e1; j++) bar = bar "█" }
if (e2 - e1 > 0) { bar = bar blue; for (j = 0; j < e2 - e1; j++) bar = bar "█" }
if (e3 - e2 > 0) { bar = bar white; for (j = 0; j < e3 - e2; j++) bar = bar "█" }
bar = bar reset
printf "%-8s %4d %s\n", w, t, bar
}
print ""
legend = ""
if (a1 != "") legend = legend red "██" reset " " a1 " "
if (a2 != "") legend = legend blue "██" reset " " a2 " "
legend = legend white "██" reset " other"
print legend
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment