summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorJack Q <QiaoBo@outlook.com>2016-10-05 04:08:32 +0300
committerJack Q <QiaoBo@outlook.com>2016-10-05 04:08:32 +0300
commit894699351d59fe1b7b8d7d1b368a2d1515aa93bb (patch)
treea30cbbaa956e3316f72c03b2263f4ac845b15ba9 /powerlevel9k.zsh-theme
parentc4fdc8f70804fea6f543e6bbf3964301e2537e36 (diff)
fix load and ram indicator support for BSD
Diffstat (limited to 'powerlevel9k.zsh-theme')
-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'