aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpowerlevel9k.zsh-theme37
1 files changed, 21 insertions, 16 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index efde41b3..c01c9a9d 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -289,14 +289,6 @@ prompt_aws() {
fi
}
-# The 'custom` prompt provides a way for users to invoke commands and display
-# the output in a segment.
-prompt_custom() {
- local command=POWERLEVEL9K_CUSTOM_$3:u
-
- "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
-}
-
# Segment to indicate background jobs with an icon.
prompt_background_jobs() {
if [[ $(jobs -l | wc -l) -gt 0 ]]; then
@@ -407,6 +399,14 @@ prompt_context() {
fi
}
+# The 'custom` prompt provides a way for users to invoke commands and display
+# the output in a segment.
+prompt_custom() {
+ local command=POWERLEVEL9K_CUSTOM_$3:u
+
+ "$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
+}
+
# Dir: current working directory
prompt_dir() {
local current_path='%~'
@@ -492,6 +492,14 @@ prompt_ip() {
}
prompt_load() {
+ # The load segment can have three different states
+ local current_state="unknown"
+ typeset -AH load_states
+ load_states=(
+ 'critical' 'red'
+ 'warning' 'yellow'
+ 'normal' 'green'
+ )
if [[ "$OS" == "OSX" ]]; then
load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
else
@@ -502,17 +510,14 @@ prompt_load() {
load_avg_5min=${load_avg_5min//,/.}
if [[ "$load_avg_5min" -gt 10 ]]; then
- BACKGROUND_COLOR="red"
- FUNCTION_SUFFIX="_CRITICAL"
+ current_state="critical"
elif [[ "$load_avg_5min" -gt 3 ]]; then
- BACKGROUND_COLOR="yellow"
- FUNCTION_SUFFIX="_WARNING"
+ current_state="warning"
else
- BACKGROUND_COLOR="green"
- FUNCTION_SUFFIX="_NORMAL"
+ current_state="normal"
fi
- "$1_prompt_segment" "$0$FUNCTION_SUFFIX" "$2" "$BACKGROUND_COLOR" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
+ "$1_prompt_segment" "${0}${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
}
# Node version
@@ -639,7 +644,7 @@ prompt_rvm() {
fi
}
-# Status: (return code, root status, background jobs)
+# Status: return code if verbose, otherwise just an icon if an error occurred
set_default POWERLEVEL9K_STATUS_VERBOSE true
prompt_status() {
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then