Skip to content

Instantly share code, notes, and snippets.

@paulbaumgart
Created July 6, 2011 08:38
Show Gist options
  • Save paulbaumgart/1066845 to your computer and use it in GitHub Desktop.
Save paulbaumgart/1066845 to your computer and use it in GitHub Desktop.
Plot the length history of a file in a git repo
file_length_history() {
export filename="$1"
(
echo set xlabel \"Days Ago\"
echo set ylabel \"Bytes\"
echo plot \"-\" title \"$filename\" with lines
now=$(date +"%s")
git log --reverse --format=format:"%at %H" "$filename" | \
while read -a line; do
echo -en "$(echo scale=10\; \(${line[0]} - $now\) / 24 / 60 / 60 | bc)\t"
git cat-file -s $(git ls-tree ${line[1]} -- "$filename" | cut -d ' ' -f 3 | cut -f 1)
done
unset filename
) | gnuplot -p
}
# Example:
# file_length_history Current-Todo.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment