mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
RAM: clean up format handling
This commit is contained in:
parent
e2a7f5f8fc
commit
898bf90ce1
|
|
@ -10,9 +10,7 @@ print_ram_percentage() {
|
|||
ram_percentage_format=$(get_tmux_option "@ram_percentage_format" "$ram_percentage_format")
|
||||
|
||||
if command_exists "free"; then
|
||||
IFS=' ' read -ra numbers <<< "$(free | sed '/^\s*$/d' | grep "Mem:" | tr -s ' ' )"
|
||||
ram=$(bc <<< "scale=6; 100 * ${numbers[2]} / ${numbers[1]}" | awk -v format="$ram_percentage_format" '{usage=$1} END {printf(format,usage)}')
|
||||
echo "$ram" # I get an extra percent if I don't use the variable for some reason
|
||||
free | awk -v format="$ram_percentage_format" '$1 == "Mem:" {printf(format, 100*$3/$2)}'
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue