summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Cohen <raphael.cohen.utt@gmail.com>2017-03-04 21:42:51 +0300
committerRaphaël Cohen <raphael.cohen.utt@gmail.com>2017-03-04 21:42:51 +0300
commitc0eadd1cb5729f16c6574957f061894348848613 (patch)
tree33031b860c1465de8be69ba44192e5d956246ed5
parent51d971a032c20295ec811a41f71f3f4b48a95827 (diff)
Improves ram prompt
For OS X display the sum of Pages free and Pages inactive For Non BSD use MemAvailable instead of MemFree
-rwxr-xr-xpowerlevel9k.zsh-theme5
1 files changed, 4 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 5fab0190..6a137049 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -891,7 +891,10 @@ prompt_ram() {
local base=''
local ramfree=0
if [[ "$OS" == "OSX" ]]; then
+ # Available = Free + Inactive
+ # See https://support.apple.com/en-us/HT201538
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
+ ramfree=$((ramfree + $(vm_stat | grep "Pages inactive" | grep -o -E '[0-9]+')))
# Convert pages into Bytes
ramfree=$(( ramfree * 4096 ))
else
@@ -899,7 +902,7 @@ prompt_ram() {
ramfree=$(vmstat | grep -E '([0-9]+\w+)+' | awk '{print $5}')
base='M'
else
- ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
+ ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
base='K'
fi
fi