git-effort: adjust column limit according to the paths

Fix #780.
This commit is contained in:
spacewander 2019-09-23 10:28:16 +08:00
parent ff0b1cfb0b
commit 7015501161

View file

@ -177,10 +177,6 @@ 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 }' | sort -rn | head -1 ) + 5 ))
export columns
# [path ...]
if test "${#paths}" -eq 0; then
@ -191,6 +187,17 @@ if test "${#paths}" -eq 0; then
unset save_ifs
fi
# set column width to match longest filename
max=0
for path in "${paths[@]}"; do
cur=${#path}
if [[ $max -lt $cur ]]; then
max=$cur
fi
done
columns=$(( max + 5 ))
export columns
# hide cursor
hide_cursor