dotfiles
shell, editor, ssh.
git clone https://owenrusk.dev/dotfiles.git
dotfiles / bin/srcstat -rwxr-xr-x · 546 bytes
1 #!/bin/sh
2 # what's uncommitted or unpushed under ~/src. "-" ahead means no upstream.
3 src=${SRC:-$HOME/src}
4
5 for dir in "$src"/*/; do
6 [ -d "$dir.git" ] || continue
7 name=$(basename "$dir")
8 branch=$(git -C "$dir" branch --show-current)
9 changed=$(git -C "$dir" status --porcelain | wc -l | tr -d ' ')
10 ahead=$(git -C "$dir" rev-list --count '@{upstream}..HEAD' 2>/dev/null || echo -)
11 [ "$changed" = 0 ] && [ "$ahead" = 0 ] && continue
12 printf '%-24s %-16s %4s changed %4s ahead\n' "$name" "$branch" "$changed" "$ahead"
13 done