summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorTim Otlik <t.otlik@handelsblattgroup.com>2018-05-08 11:50:04 +0300
committerTim Otlik <t.otlik@handelsblattgroup.com>2018-05-08 11:50:04 +0300
commit3c27f14581086ab04bf7de9f69c24bdaf3e6de45 (patch)
treef57564096a88a406150701052f63847a5861404b /powerlevel9k.zsh-theme
parent7234d52ebd76b6b89e172ac5b19339f0a37ab596 (diff)
add new option "POWERLEVEL9K_BATTERY_HIDE_FULL"
Hides the battery segment if percentage hits 100%
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme27
1 files changed, 20 insertions, 7 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 8f06866f..0ac0b938 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -488,14 +488,27 @@ prompt_battery() {
fi
fi
- # override the default color if we are using a color level array
- if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
- local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
- local offset=$(( ($bat_percent / $segment) + 1 ))
- "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ if [[ -v "POWERLEVEL9K_BATTERY_HIDE_FULL" && "$POWERLEVEL9K_BATTERY_HIDE_FULL" == true ]]; then
+ if [[ "$bat_percent" != "100" ]]; then
+ if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
+ local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
+ local offset=$(( ($bat_percent / $segment) + 1 ))
+ "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ else
+ # Draw the prompt_segment
+ "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ fi
+ fi
else
- # Draw the prompt_segment
- "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ # override the default color if we are using a color level array
+ if [[ -n "$POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND" ]] && [[ "${(t)POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND}" =~ "array" ]]; then
+ local segment=$(( 100.0 / (${#POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND} - 1 ) ))
+ local offset=$(( ($bat_percent / $segment) + 1 ))
+ "$1_prompt_segment" "$0_${current_state}" "$2" "${POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[$offset]}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ else
+ # Draw the prompt_segment
+ "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ fi
fi
}