aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-10-26 18:17:31 +0300
committerGitHub <noreply@github.com>2016-10-26 18:17:31 +0300
commit3c92cf9748cff350a14cc8f42eda439c5fe01baa (patch)
tree22a2766c05db580b26e8d35a1f9890d85a4b309d
parent790230e1c7e03198d39e2ecc908b40af1d25f373 (diff)
parent894699351d59fe1b7b8d7d1b368a2d1515aa93bb (diff)
Merge pull request #321 from Jack-Q/master
Fix load and ram indicator support for BSD
-rwxr-xr-xpowerlevel9k.zsh-theme17
1 files changed, 13 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 0860cff4..87678149 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -590,9 +590,13 @@ prompt_load() {
'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)
- cores=$(sysctl -n hw.logicalcpu)
+ if [[ "$OS" == "OSX" ]]; then
+ cores=$(sysctl -n hw.logicalcpu)
+ else
+ cores=$(sysctl -n hw.ncpu)
+ fi
else
load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
cores=$(nproc)
@@ -665,8 +669,13 @@ prompt_ram() {
# Convert pages into Bytes
ramfree=$(( ramfree * 4096 ))
else
- ramfree=$(grep -o -E "MemFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
- base='K'
+ if [[ "$OS" == "BSD" ]]; then
+ 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]*")
+ base='K'
+ fi
fi
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'