aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorTim Otlik <t.otlik@vivaldi.net>2018-05-09 11:18:06 +0300
committerTim Otlik <t.otlik@vivaldi.net>2018-05-09 11:18:06 +0300
commit642034eef2b455aa75819e4c394cd4416206665b (patch)
treeed6fc37a50c57b21d23657b911cc3f240f8ee6a1 /powerlevel9k.zsh-theme
parent3c27f14581086ab04bf7de9f69c24bdaf3e6de45 (diff)
remove duplicate code in battery segment
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme49
1 files changed, 20 insertions, 29 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 0ac0b938..45d0cc25 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -488,28 +488,19 @@ prompt_battery() {
fi
fi
- 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
- # 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
+ if [[ "${POWERLEVEL9K_BATTERY_HIDE_FULL}" == "true" && "${bat_percent}" = 100 ]]; then
+ return
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"
+ else
+ # Draw the prompt_segment
+ "$1_prompt_segment" "$0_${current_state}" "$2" "${DEFAULT_COLOR}" "${battery_states[$current_state]}" "${message}" "BATTERY_ICON"
+ fi
}
################################################################
@@ -650,14 +641,14 @@ prompt_user() {
"FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "ROOT_ICON"
)
- elif sudo -n true 2>/dev/null; then
- user_state=(
- "STATE" "SUDO"
- "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
- "BACKGROUND_COLOR" "${DEFAULT_COLOR}"
- "FOREGROUND_COLOR" "yellow"
- "VISUAL_IDENTIFIER" "SUDO_ICON"
- )
+ elif sudo -n true 2>/dev/null; then
+ user_state=(
+ "STATE" "SUDO"
+ "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
+ "BACKGROUND_COLOR" "${DEFAULT_COLOR}"
+ "FOREGROUND_COLOR" "yellow"
+ "VISUAL_IDENTIFIER" "SUDO_ICON"
+ )
else
user_state=(
"STATE" "DEFAULT"