Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Last active August 29, 2015 14:05
Show Gist options
  • Save rummelonp/98586afb3cd19478c5a2 to your computer and use it in GitHub Desktop.
Save rummelonp/98586afb3cd19478c5a2 to your computer and use it in GitHub Desktop.
git で今週の総追加行数/総削除行数を出すサブコマンド改 http://mitukiii.hatenablog.com/entry/2014/08/14/221805
#!/usr/bin/env bash
stats() {
local desc="$1"
local from="$2"
local to="${3:-$from}"
local since="$(date -v${from} +'%Y-%m-%d') 00:00:00"
local until="$(date -v${to} +'%Y-%m-%d') 23:59:59"
echo $desc
git log --oneline --shortstat --no-merges --since="'$since'" --until="'$until'" \
| grep -E 'files? changed' \
| awk 'BEGIN { i=0; d=0 }
{ i+=$4; d+=$6 }
END { print " " i " insertions(+), " d " deletions(-)" }'
}
stats 'This week' -6d +0d
stats 'Today' +0d
stats 'Yesterday' -1d
stats '2 days ago' -2d
stats '3 days ago' -3d
stats '4 days ago' -4d
stats '5 days ago' -5d
stats '6 days ago' -6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment