From 9191d29c96c82978bd461c2a4e182599783179ae Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 4 Sep 2015 18:30:04 +0200 Subject: [PATCH 1/2] In case that two subsequent segments have the same background color, now a small separator is displayed. Before this commit, no segment separator was shown and the two segments looked like one. --- powerlevel9k.zsh-theme | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 974273e7..a4bc79bd 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -75,6 +75,8 @@ case $POWERLEVEL9K_MODE in icons=( LEFT_SEGMENT_SEPARATOR "\UE0B0" #  RIGHT_SEGMENT_SEPARATOR "\UE0B2" #  + LEFT_SUBSEGMENT_SEPARATOR "\UE0B1" #  + RIGHT_SUBSEGMENT_SEPARATOR "\UE0B3" #  ROOT_ICON "\UE801" #  RUBY_ICON "\UE847" #  AWS_ICON "\UE895" #  @@ -116,6 +118,8 @@ case $POWERLEVEL9K_MODE in icons=( LEFT_SEGMENT_SEPARATOR "\uE0B0" #  RIGHT_SEGMENT_SEPARATOR "\uE0B2" #  + LEFT_SUBSEGMENT_SEPARATOR "\UE0B1" #  + RIGHT_SUBSEGMENT_SEPARATOR "\UE0B3" #  ROOT_ICON "\u26A1" # ⚡ RUBY_ICON '' AWS_ICON "AWS:" @@ -313,6 +317,14 @@ left_prompt_segment() { if [[ $CURRENT_BG != 'NONE' && $2 != $CURRENT_BG ]]; then # Middle segment echo -n "%{$bg%F{$CURRENT_BG}%}$(print_icon 'LEFT_SEGMENT_SEPARATOR')%{$fg%} " + elif [[ "$CURRENT_BG" == $2 ]]; then + # Middle segment with same color as previous segment + # We take the current foreground color as color for our + # subsegment (or the default color). This should have + # enough contrast. + local complement + [[ -n $3 ]] && complement=$3 || complement=$DEFAULT_COLOR + echo -n "%{$bg%F{$complement}%}$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')%{$fg%} " else # First segment echo -n "%{$bg%}%{$fg%} " @@ -332,6 +344,8 @@ left_prompt_end() { CURRENT_BG='' } +CURRENT_RIGHT_BG='NONE' + # Begin a right prompt segment # Takes four arguments: # * $1: Name of the function that was orginally invoked (mandatory). @@ -354,8 +368,21 @@ right_prompt_segment() { local bg fg [[ -n $2 ]] && bg="%K{$2}" || bg="%k" [[ -n $3 ]] && fg="%F{$3}" || fg="%f" - echo -n "%f%F{$2}$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f%{$bg%}%{$fg%} " + + if [[ "$CURRENT_RIGHT_BG" == $2 ]]; then + # Middle segment with same color as previous segment + # We take the current foreground color as color for our + # subsegment (or the default color). This should have + # enough contrast. + local complement + [[ -n $3 ]] && complement=$3 || complement=$DEFAULT_COLOR + echo -n "%f%F{$complement}$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f%{$bg%}%{$fg%} " + else + echo -n "%f%F{$2}$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f%{$bg%}%{$fg%} " + fi [[ -n $4 ]] && echo -n "$4 " + + CURRENT_RIGHT_BG=$2 } ################################################################ From 5a8a6c8012a35b4dc950fdbe54b2ff7a7a0c7db8 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 4 Sep 2015 18:32:44 +0200 Subject: [PATCH 2/2] The foreground color of the `longstatus` segment should be white. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a4bc79bd..e0b5eecd 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -567,7 +567,7 @@ prompt_longstatus() { [[ "$UID" -eq 0 ]] && symbols+="%{%F{yellow}%} $(print_icon 'ROOT_ICON')" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$(print_icon 'BACKGROUND_JOBS_ICON')" - [[ -n "$symbols" ]] && $1_prompt_segment "$0" "$bg" "$DEFAULT_COLOR" "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment "$0" "$bg" "white" "$symbols" } # Node version