mirror of https://github.com/aristocratos/bashtop
Fixed humanizer function by rounding values 1000-1023 up to 1024 to fit.
parent
f664330607
commit
6f69588d78
12
bashtop
12
bashtop
|
@ -852,10 +852,11 @@ floating_humanizer() { #? Convert integer to floating point and scale up in ste
|
||||||
|
|
||||||
until ((${#value}<6)); do
|
until ((${#value}<6)); do
|
||||||
value=$((value>>10))
|
value=$((value>>10))
|
||||||
|
if ((value<100)); then value=100; fi
|
||||||
((++selector))
|
((++selector))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z $short ]] && ((${#value}<5 & ${#value}>=2 & selector>0)); then
|
if ((${#value}<5 & ${#value}>=2 & selector>0)); then
|
||||||
decimals=$((5-${#value}))
|
decimals=$((5-${#value}))
|
||||||
value="${value::-2}.${value:(-${decimals})}"
|
value="${value::-2}.${value:(-${decimals})}"
|
||||||
elif ((${#value}>=2)); then
|
elif ((${#value}>=2)); then
|
||||||
|
@ -863,6 +864,8 @@ floating_humanizer() { #? Convert integer to floating point and scale up in ste
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $short ]]; then value="${value%.*}"; fi
|
||||||
|
|
||||||
out_var="${value}${sep}${unit[$selector]::${short:-${#unit[$selector]}}}${per_second}"
|
out_var="${value}${sep}${unit[$selector]::${short:-${#unit[$selector]}}}${per_second}"
|
||||||
if [[ -z $ext_var ]]; then echo -n "${out_var}"; fi
|
if [[ -z $ext_var ]]; then echo -n "${out_var}"; fi
|
||||||
}
|
}
|
||||||
|
@ -4814,6 +4817,9 @@ if [[ $use_psutil == true ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#* if we have been sourced by another shell, quit. Allows sourcing only function definition.
|
||||||
|
[[ "${#BASH_SOURCE[@]}" -gt 1 ]] && { return 0; }
|
||||||
|
|
||||||
#* Set up traps for ctrl-c, soft kill, window resize, ctrl-z and resume from ctrl-z
|
#* Set up traps for ctrl-c, soft kill, window resize, ctrl-z and resume from ctrl-z
|
||||||
trap 'quitting=1; time_left=0' SIGINT SIGQUIT SIGTERM
|
trap 'quitting=1; time_left=0' SIGINT SIGQUIT SIGTERM
|
||||||
trap 'resized=1; time_left=0' SIGWINCH
|
trap 'resized=1; time_left=0' SIGWINCH
|
||||||
|
@ -4842,10 +4848,6 @@ else
|
||||||
exec 2>/dev/null
|
exec 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#* if we have been sourced by another shell, quit. Allows sourcing only function definition.
|
|
||||||
[[ "${#BASH_SOURCE[@]}" -gt 1 ]] && { return 0; }
|
|
||||||
|
|
||||||
#* Call init function
|
#* Call init function
|
||||||
init_
|
init_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue