Replace tput with $COLUMNS

This commit is contained in:
eightpigs 2018-04-14 21:07:19 +08:00
parent be554c4bf6
commit 2b35ac9f45

View File

@ -14,15 +14,11 @@ year_progress() {
# progress=current/year # progress=current/year
value=`echo "$current $len" | awk '{printf ("%.2f\n",$1/$2)}'` value=`echo "$current $len" | awk '{printf ("%.2f\n",$1/$2)}'`
# Get the number of columns in the terminal
tput init
cols=`tput cols`
val2=$(($current*100/$len)) val2=$(($current*100/$len))
info=$val2%' '$current/$len info=$val2%' '$current/$len
cols=$(($cols-${#info})) cols=$(($COLUMNS-${#info}))
# Fill the proportion of the screen # Fill the proportion of the screen
scale=`echo "$cols" | awk '{printf ("%.2f\n",$1/100)}'` scale=`echo "$cols" | awk '{printf ("%.2f\n",$1/100)}'`