mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-14 00:50:08 +00:00
fix load and ram indicator support for BSD
This commit is contained in:
parent
c4fdc8f708
commit
894699351d
1 changed files with 13 additions and 4 deletions
|
@ -590,9 +590,13 @@ prompt_load() {
|
||||||
'normal' 'green'
|
'normal' 'green'
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ "$OS" == "OSX" ]]; then
|
if [[ "$OS" == "OSX" ]] || [[ "$OS" == "BSD" ]]; then
|
||||||
load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
|
load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
|
||||||
|
if [[ "$OS" == "OSX" ]]; then
|
||||||
cores=$(sysctl -n hw.logicalcpu)
|
cores=$(sysctl -n hw.logicalcpu)
|
||||||
|
else
|
||||||
|
cores=$(sysctl -n hw.ncpu)
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
|
load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
|
||||||
cores=$(nproc)
|
cores=$(nproc)
|
||||||
|
@ -664,10 +668,15 @@ prompt_ram() {
|
||||||
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
|
ramfree=$(vm_stat | grep "Pages free" | grep -o -E '[0-9]+')
|
||||||
# Convert pages into Bytes
|
# Convert pages into Bytes
|
||||||
ramfree=$(( ramfree * 4096 ))
|
ramfree=$(( ramfree * 4096 ))
|
||||||
|
else
|
||||||
|
if [[ "$OS" == "BSD" ]]; then
|
||||||
|
ramfree=$(vmstat | grep -E '([0-9]+\w+)+' | awk '{print $5}')
|
||||||
|
base='M'
|
||||||
else
|
else
|
||||||
ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||||
base='K'
|
base='K'
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
|
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue