From ac2f789ff4b5419791347b7f1afb09b5f7eeee55 Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sat, 13 Jun 2020 21:42:27 -0400 Subject: [PATCH] Fixed reviews --- scripts/ram_info.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index f9d207c..8f4d40a 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -18,9 +18,14 @@ get_percent() Darwin) # percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}') - used_mem=$(top -l 1 -s 0 | grep PhysMem | awk '{print $2 $3}' | sed 's/used//g') - total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}' | sed 's/used//g') - echo $used_mem/$total_mem + used_mem=$(vm_stat | grep -i "Pages active:" | sed 's/\.//g' | awk '{printf "%d", $3*4096/1024/1024}') + total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}') + if (( $used_mem < 1024 )); then + echo $used_mem\M\B/$total_mem + else + memory=$(($used_mem / 1024)) + echo $memory\G\B/$total_mem + fi ;; CYGWIN*|MINGW32*|MSYS*|MINGW*)