Skip to content

Instantly share code, notes, and snippets.

@marsam
Created October 26, 2013 14:25
Show Gist options
  • Select an option

  • Save marsam/7170029 to your computer and use it in GitHub Desktop.

Select an option

Save marsam/7170029 to your computer and use it in GitHub Desktop.
git stats
#!/bin/sh
#
# Usage:
# git stats --author mario
# git stats --author pepe@lucho.org --since yesterday
git_statistics(){
git log --shortstat --oneline $@ |
grep -E "fil(e|es) changed" |
awk '
function cyan(string){
return sprintf("\033[36m%s\033[0m", string)
}
function red(string){
return sprintf("\033[31m%s\033[0m", string)
}
function green(string){
return sprintf("\033[32m%s\033[0m", string)
}
BEGIN { files=0; insertions=0; deletions=0 }
{ files+=$1; insertions+=$4; deletions+=$6 }
END { printf("%s files changed, %s insertions, %s deletions\n", cyan(files), green(insertions), red(deletions))}'
}
git_statistics $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment