🐛 fix(#165): is no longer based on word matching

Signed-off-by: Adrien Kara <adrien@iglou.eu>
This commit is contained in:
Adrien Kara 2023-01-07 18:36:14 +01:00
parent ffc6ef8efb
commit beb6085ad7
No known key found for this signature in database
GPG key ID: 605B69551C56DB62

View file

@ -9,20 +9,11 @@ get_percent()
{ {
case $(uname -s) in case $(uname -s) in
Linux) Linux)
total_mem_gb=$(free -g | awk '/^Mem/ {print $2}') usage="$(free -h | awk 'NR==2 {print $3}')"
used_mem=$(free -g | awk '/^Mem/ {print $3}') total="$(free -h | awk 'NR==2 {print $2}')"
total_mem=$(free -h | awk '/^Mem/ {print $2}') formated="${usage}/${total}"
if (( $total_mem_gb == 0)); then
memory_usage=$(free -m | awk '/^Mem/ {print $3}') echo "${formated//i/B}"
total_mem_mb=$(free -m | awk '/^Mem/ {print $2}')
echo $memory_usage\M\B/$total_mem_mb\M\B
elif (( $used_mem == 0 )); then
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
echo $memory_usage\M\B/$total_mem_gb\G\B
else
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
echo $memory_usage\G\B/$total_mem_gb\G\B
fi
;; ;;
Darwin) Darwin)