mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-19 14:01:57 +00:00
Improves ram prompt
For OS X display the sum of Pages free and Pages inactive For Non BSD use MemAvailable instead of MemFree
This commit is contained in:
parent
51d971a032
commit
c0eadd1cb5
1 changed files with 4 additions and 1 deletions
|
@ -891,7 +891,10 @@ prompt_ram() {
|
||||||
local base=''
|
local base=''
|
||||||
local ramfree=0
|
local ramfree=0
|
||||||
if [[ "$OS" == "OSX" ]]; then
|
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=$(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
|
# Convert pages into Bytes
|
||||||
ramfree=$(( ramfree * 4096 ))
|
ramfree=$(( ramfree * 4096 ))
|
||||||
else
|
else
|
||||||
|
@ -899,7 +902,7 @@ prompt_ram() {
|
||||||
ramfree=$(vmstat | grep -E '([0-9]+\w+)+' | awk '{print $5}')
|
ramfree=$(vmstat | grep -E '([0-9]+\w+)+' | awk '{print $5}')
|
||||||
base='M'
|
base='M'
|
||||||
else
|
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'
|
base='K'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue