aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <david.runge@native-instruments.de>2018-04-23 08:43:06 +0200
committerDavid Runge <david.runge@native-instruments.de>2018-04-23 08:43:06 +0200
commit33824987fd7d8764288bcd1814ada49a16a68f15 (patch)
tree67a9f729d3a27a80b9a0e9f6902618f228bac2fa /bin
parent21c82ea77a7ab6ed9862eef7c604988995015cb5 (diff)
downloaddotfiles-33824987fd7d8764288bcd1814ada49a16a68f15.tar.gz
dotfiles-33824987fd7d8764288bcd1814ada49a16a68f15.tar.bz2
dotfiles-33824987fd7d8764288bcd1814ada49a16a68f15.tar.xz
dotfiles-33824987fd7d8764288bcd1814ada49a16a68f15.zip
bin/get_mem: Make script support macOS (using ps).
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get_mem10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/get_mem b/bin/get_mem
index fc49561..21cf04a 100755
--- a/bin/get_mem
+++ b/bin/get_mem
@@ -4,8 +4,12 @@ IFS=$'\n\t'
mem_output=""
-mem_output="$(free -m| grep "Mem:"| awk '{printf $3 "/" $2 " ("} {printf ("%1.3f", $3/$2)} {printf ")"}')"
+if [ "$(uname)" == "Darwin" ]; then
+ mem_output=$(ps -A -o %mem | awk '{s+=$1} END {print s}')
+else
+ mem_output="$(free -m| grep "Mem:"| awk '{printf $3 "/" $2 " ("} {printf ("%1.3f", $3/$2)} {printf ")"}')"
+fi
-echo "$mem_output"
-exit 0
+echo "$mem_output%"
+exit 0