#!/bin/sh

files=`git ls-files`
above='0'

if test "$1" = "--above"; then
  above=$2
fi

echo
echo "  file                                          commits"
echo

for file in $files; do
  commits=`git log --oneline $file | wc -l`
  color='90'

  if test $commits -le $above; then
    continue
  fi

  test $commits -gt 10 && color='33'
  test $commits -gt 25 && color='33;1'
  test $commits -gt 50 && color='93'
  test $commits -gt 75 && color='93;1'
  test $commits -gt 100 && color='31'
  test $commits -gt 125 && color='31;1'
  test $commits -gt 150 && color='91'
  test $commits -gt 200 && color='91;1'

  printf "  \033[${color}m%-45s %d\033[0m\n" $file $commits
done
echo
