summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme48
1 files changed, 44 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index c3f2be74..f104b789 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -337,6 +337,48 @@ prompt_background_jobs() {
fi
}
+# Segment that indicates usage level of current partition.
+set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false
+set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90
+set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95
+prompt_disk_usage() {
+ local current_state="unknown"
+ typeset -AH hdd_usage_forecolors
+ hdd_usage_forecolors=(
+ 'normal' 'yellow'
+ 'warning' "$DEFAULT_COLOR"
+ 'critical' 'white'
+ )
+ typeset -AH hdd_usage_backcolors
+ hdd_usage_backcolors=(
+ 'normal' $DEFAULT_COLOR
+ 'warning' 'yellow'
+ 'critical' 'red'
+ )
+
+ local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}"
+
+ if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then
+ current_state='warning'
+ if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then
+ current_state='critical'
+ fi
+ else
+ if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then
+ current_state=''
+ return
+ fi
+ current_state='normal'
+ fi
+
+ local message="${disk_usage}%%"
+
+ # Draw the prompt_segment
+ if [[ -n $disk_usage ]]; then
+ "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON'
+ fi
+}
+
prompt_battery() {
# The battery can have four different states - default to 'unknown'.
local current_state='unknown'
@@ -1065,12 +1107,10 @@ prompt_pyenv() {
# Swift version
prompt_swift_version() {
- local swift_version=($(swift --version 2>/dev/null))
+ # Get the first number as this is probably the "main" version number..
+ local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1)
[[ -z "${swift_version}" ]] && return
- # Extract semantic version
- swift_version=$(echo ${swift_version} | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/')
-
"$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON'
}