From 518db6e648aaf646db4be3067a583bdcc37ee2a8 Mon Sep 17 00:00:00 2001 From: Niklas Schlimm Date: Sat, 4 Mar 2017 13:59:48 +0100 Subject: [PATCH 1/3] Columns in git-effort adopt to file length --- bin/git-effort | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 4528ec9a3..8829451ec 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -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 From b01359efc5761a17cd3b893fd51219a005009641 Mon Sep 17 00:00:00 2001 From: Niklas Schlimm Date: Sat, 4 Mar 2017 14:21:26 +0100 Subject: [PATCH 2/3] Optimized file length calculation --- bin/git-effort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 8829451ec..2a4a77272 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -179,7 +179,7 @@ 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 )) +columns=$(( $(git ls-files | awk '{ print length }' | sort -rn | head -1 ) + 5 )) export columns # [path ...] From 422c9a8e69acc5cf013340715f8d2fa7d7cabf75 Mon Sep 17 00:00:00 2001 From: Niklas Schlimm Date: Sun, 5 Mar 2017 16:06:47 +0100 Subject: [PATCH 3/3] taken out duplicate columns setting --- bin/git-effort | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 2a4a77272..e4bc12ade 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -5,7 +5,6 @@ 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