Columns in git-effort adopt to file length

This commit is contained in:
Niklas Schlimm 2017-03-04 13:59:48 +01:00
parent 2289c25029
commit 518db6e648

View file

@ -5,6 +5,7 @@ above=0
# if the output won't be printed to tty, disable the color
test -t 1 && to_tty=true
color=
columns=45
#
# print usage message
@ -104,7 +105,7 @@ effort() {
len=${#path}
dot="."
f_dot="$path"
i=0 ; while test $i -lt $((45-$len)) ; do
i=0 ; while test $i -lt $(( $columns - $len )) ; do
f_dot=$f_dot$dot
i=$(($i+1))
done
@ -124,7 +125,7 @@ effort() {
heading() {
echo
printf " %-45s %-10s %s\n" 'path' 'commits' 'active days'
printf " %-${columns}s %-10s %s\n" 'path' 'commits' 'active days'
echo
}
@ -177,6 +178,10 @@ fi
args_to_git_log="${args_to_git_log#\ \'\'}"
export args_to_git_log
# set column width to match longest filename
columns=$(( $(git ls-files | awk '{ print length, $0 }' | sort -rn | head -1 | cut -f1 -d' ') + 5 ))
export columns
# [path ...]
if test "${#paths}" -eq 0; then