From 71510361984568408f8dc87251c1a9e2abdddef2 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:31:09 +0100 Subject: [PATCH 01/27] Removed unecessary variable. --- functions/icons.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index fcf08163..48396ff5 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -190,9 +190,8 @@ fi function print_icon() { local icon_name=$1 local ICON_USER_VARIABLE=POWERLEVEL9K_${icon_name} - local USER_ICON=${(P)ICON_USER_VARIABLE} if defined "$ICON_USER_VARIABLE"; then - echo -n "$USER_ICON" + echo -n "${(P)ICON_USER_VARIABLE}" else echo -n "${icons[$icon_name]}" fi From 21f80e4da711dd4d1e81e1f58887519cfc7a038c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:32:45 +0100 Subject: [PATCH 02/27] Removed trailing whitespaces. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3d2d5d2c..9842bfa9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -782,7 +782,7 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" RPROMPT_PREFIX='%{'$'\e[1A''%}' # one line up RPROMPT_SUFFIX='%{'$'\e[1B''%}' # one line down else - RPROMPT_PREFIX='' + RPROMPT_PREFIX='' RPROMPT_SUFFIX='' fi else @@ -838,7 +838,7 @@ powerlevel9k_init() { print_deprecation_warning deprecated_segments setopt prompt_subst - + setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS setopt PROMPT_CR PROMPT_PERCENT PROMPT_SUBST MULTIBYTE From 036433dd538f55d2950d40b0ca3068016877314f Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:41:02 +0100 Subject: [PATCH 03/27] Segments now can have "visual identifiers" which are basically just special icons. --- powerlevel9k.zsh-theme | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9842bfa9..4705a89b 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -123,7 +123,8 @@ CURRENT_BG='NONE' # * $2: Background color # * $3: Foreground color # * $4: The segment content -# The latter three can be omitted, +# * $5: An identifying icon (must be a key of the icons array) +# The latter four can be omitted, set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " " left_prompt_segment() { # Overwrite given background-color by user defined variable for this segment. @@ -154,8 +155,16 @@ left_prompt_segment() { # First segment echo -n "%{$bg%}%{$fg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" fi + + local visual_identifier + if [[ -n $5 ]]; then + visual_identifier="$(print_icon $5)" + # Add an whitespace if we print more than just the visual identifier + [[ -n $4 ]] && visual_identifier="$visual_identifier " + fi + + echo -n "$visual_identifier$4$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" CURRENT_BG=$2 - [[ -n $4 ]] && echo -n "$4$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" } # End the left prompt, closes the final segment. @@ -178,6 +187,7 @@ CURRENT_RIGHT_BG='NONE' # * $2: Background color # * $3: Foreground color # * $4: The segment content +# * $5: An identifying icon (must be a key of the icons array) # No ending for the right prompt segment is needed (unlike the left prompt, above). set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " " right_prompt_segment() { @@ -206,8 +216,16 @@ right_prompt_segment() { else echo -n "%F{$2}$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f%{$bg%}%{$fg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS" fi - [[ -n $4 ]] && echo -n "$4$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS%f" + local visual_identifier + if [[ -n $5 ]]; then + # Swap the spaces around an icon if the icon is displayed on the right side. + visual_identifier=$(print_icon $5 | sed -E "s/( *)([^ ]*)( *)/\3\2\1/") + # Add an whitespace if we print more than just the visual identifier + [[ -n $4 ]] && visual_identifier=" $visual_identifier" + fi + + echo -n "$4$visual_identifier$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS%f" CURRENT_RIGHT_BG=$2 } From 0c528461fb1e5f38e1d4ee32c696a6955f5bfaa0 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:55:24 +0100 Subject: [PATCH 04/27] Allow users to overwrite the color for the visual identifier only. --- powerlevel9k.zsh-theme | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4705a89b..7c7b2d2e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -159,6 +159,10 @@ left_prompt_segment() { local visual_identifier if [[ -n $5 ]]; then visual_identifier="$(print_icon $5)" + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $fg + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" # Add an whitespace if we print more than just the visual identifier [[ -n $4 ]] && visual_identifier="$visual_identifier " fi @@ -221,6 +225,10 @@ right_prompt_segment() { if [[ -n $5 ]]; then # Swap the spaces around an icon if the icon is displayed on the right side. visual_identifier=$(print_icon $5 | sed -E "s/( *)([^ ]*)( *)/\3\2\1/") + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $fg + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" # Add an whitespace if we print more than just the visual identifier [[ -n $4 ]] && visual_identifier=" $visual_identifier" fi From 1194826ef4eb876edbf3cec427eca37eda976a02 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:55:55 +0100 Subject: [PATCH 05/27] Used the new "visual identifier" concept for the battery segment. --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7c7b2d2e..7a06002a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -346,15 +346,15 @@ prompt_battery() { fi # prepare string - local message="$(print_icon 'BATTERY_ICON')" + local message # Default behavior: Be verbose! set_default POWERLEVEL9K_BATTERY_VERBOSE true if [[ "$POWERLEVEL9K_BATTERY_VERBOSE" == true ]]; then - message="$message $bat_percent%%$remain" + message="$bat_percent%%$remain" fi # display prompt_segment - [[ -n $bat_percent ]] && "$1_prompt_segment" "${0}_${current_state}" "$DEFAULT_COLOR" "${battery_states[$current_state]}" "$message" + [[ -n $bat_percent ]] && "$1_prompt_segment" "${0}_${current_state}" "$DEFAULT_COLOR" "${battery_states[$current_state]}" "$message" 'BATTERY_ICON' } # Context: user@hostname (who am I and where am I) From e505c0698e12a8769ced7e0f0bc42c3b7df3210e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:57:24 +0100 Subject: [PATCH 06/27] Added the "visual identifier" concept to the `aws` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7a06002a..64427545 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -251,7 +251,7 @@ prompt_aws() { local aws_profile="$AWS_DEFAULT_PROFILE" if [[ -n "$aws_profile" ]]; then - "$1_prompt_segment" "$0" red white "$(print_icon 'AWS_ICON') $aws_profile" + "$1_prompt_segment" "$0" red white "$aws_profile" 'AWS_ICON' fi } From d5d5acb490e37d62db30a16fb434dce56c732c05 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:58:36 +0100 Subject: [PATCH 07/27] Added the "visual identifier" concept to the `dir` segment. --- powerlevel9k.zsh-theme | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 64427545..b0abe8c1 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -391,12 +391,10 @@ prompt_dir() { local current_icon='' if [[ $(print -P "%~") == '~'* ]]; then - current_icon=$(print_icon 'HOME_ICON') + "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_path" 'HOME_ICON' else - current_icon=$(print_icon 'FOLDER_ICON') + "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_path" 'FOLDER_ICON' fi - - "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_icon$current_path" } # GO-prompt From bb5cca9af7d678d5a70ea529e75ba740c0caa6b4 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 00:59:39 +0100 Subject: [PATCH 08/27] Added the "visual identifier" concept to the `ip` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b0abe8c1..1258b0ec 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -449,7 +449,7 @@ prompt_ip() { fi fi - "$1_prompt_segment" "$0" "cyan" "$DEFAULT_COLOR" "$(print_icon 'NETWORK_ICON') $ip" + "$1_prompt_segment" "$0" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON' } prompt_load() { From 35b1cb5b8d7b4132d9b1da50600265b040e94308 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:01:34 +0100 Subject: [PATCH 09/27] Added the "visual identifier" concept to the `load` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1258b0ec..d5e3b1e1 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -473,7 +473,7 @@ prompt_load() { FUNCTION_SUFFIX="_NORMAL" fi - "$1_prompt_segment" "$0$FUNCTION_SUFFIX" "$BACKGROUND_COLOR" "$DEFAULT_COLOR" "$(print_icon 'LOAD_ICON') $load_avg_5min" + "$1_prompt_segment" "$0$FUNCTION_SUFFIX" "$BACKGROUND_COLOR" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON' } # Node version From fd0fcba5e9b14f27879c209ec056d23adc189026 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:02:55 +0100 Subject: [PATCH 10/27] Added the "visual identifier" concept to the `node_version` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index d5e3b1e1..362cacb3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -481,7 +481,7 @@ prompt_node_version() { local node_version=$(node -v 2>/dev/null) [[ -z "${node_version}" ]] && return - "$1_prompt_segment" "$0" "green" "white" "${node_version:1} $(print_icon 'NODE_ICON')" + "$1_prompt_segment" "$0" "green" "white" "${node_version:1}" 'NODE_ICON' } # print a little OS icon From d514b077d09359860b9450da696e3377e5643740 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:05:42 +0100 Subject: [PATCH 11/27] Added the "visual identifier" concept to the `rvm` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 362cacb3..e3e135bb 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -589,7 +589,7 @@ prompt_rvm() { local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') if [[ -n "$version$gemset" ]]; then - "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$version$gemset $(print_icon 'RUBY_ICON') " + "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$version$gemset" 'RUBY_ICON' fi } From c5726bc548a4a8b82db480ec55ee04ceae31624e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:07:38 +0100 Subject: [PATCH 12/27] Added the "visual identifier" concept to the `todo` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index e3e135bb..9b74cd87 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -668,7 +668,7 @@ prompt_todo() { if $(hash todo.sh 2>&-); then count=$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }') if [[ "$count" = <-> ]]; then - "$1_prompt_segment" "$0" "244" "$DEFAULT_COLOR" "$(print_icon 'TODO_ICON') $count" + "$1_prompt_segment" "$0" "244" "$DEFAULT_COLOR" "$count" 'TODO_ICON' fi fi } From 6f7d6f7259d33233288dca3b5657c89550023389 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:21:15 +0100 Subject: [PATCH 13/27] For left aligned segments start the foreground color after the visual identifier has been printed. --- powerlevel9k.zsh-theme | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9b74cd87..4657d3e5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -142,7 +142,7 @@ left_prompt_segment() { [[ -n $3 ]] && fg="%F{$3}" || fg="%f" if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$2" "$CURRENT_BG"; then # Middle segment - echo -n "%{$bg%F{$CURRENT_BG}%}$(print_icon 'LEFT_SEGMENT_SEPARATOR')%{$fg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "%{$bg%F{$CURRENT_BG}%}$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" elif isSameColor "$CURRENT_BG" "$2"; then # Middle segment with same color as previous segment # We take the current foreground color as color for our @@ -150,10 +150,10 @@ left_prompt_segment() { # enough contrast. local complement [[ -n $3 ]] && complement=$3 || complement=$DEFAULT_COLOR - echo -n "%{$bg%F{$complement}%}$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')%{$fg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "%{$bg%F{$complement}%}$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" else # First segment - echo -n "%{$bg%}%{$fg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "%{$bg%}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" fi local visual_identifier @@ -167,7 +167,7 @@ left_prompt_segment() { [[ -n $4 ]] && visual_identifier="$visual_identifier " fi - echo -n "$visual_identifier$4$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" + echo -n "$visual_identifier%{$fg%}$4$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" CURRENT_BG=$2 } From 78d22ba309171889e79fa486b9f7aa882b4d8001 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 01:31:55 +0100 Subject: [PATCH 14/27] Interesting: We don't need to swap the whitespaces if the visual identifier should be rendered on the right side, because the terminal gets printed from left to right and the double width characters need their "print me right"-whitespaces on the right side anyways. --- powerlevel9k.zsh-theme | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4657d3e5..25a9f0e0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -223,8 +223,7 @@ right_prompt_segment() { local visual_identifier if [[ -n $5 ]]; then - # Swap the spaces around an icon if the icon is displayed on the right side. - visual_identifier=$(print_icon $5 | sed -E "s/( *)([^ ]*)( *)/\3\2\1/") + visual_identifier="$(print_icon $5)" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR set_default $visual_identifier_color_variable $fg From 1d0f47fb976369ce56c294e278667aad5aa20335 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 02:20:11 +0100 Subject: [PATCH 15/27] Bugfix: the default should be a pure color, not a full ZSH color modifier. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 25a9f0e0..a90d18e7 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -161,7 +161,7 @@ left_prompt_segment() { visual_identifier="$(print_icon $5)" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $fg + set_default $visual_identifier_color_variable $3 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" # Add an whitespace if we print more than just the visual identifier [[ -n $4 ]] && visual_identifier="$visual_identifier " @@ -226,7 +226,7 @@ right_prompt_segment() { visual_identifier="$(print_icon $5)" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $fg + set_default $visual_identifier_color_variable $3 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" # Add an whitespace if we print more than just the visual identifier [[ -n $4 ]] && visual_identifier=" $visual_identifier" From 46aafc797a21926734d5c40c56d68e55c8c845e3 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 02:34:23 +0100 Subject: [PATCH 16/27] Some icons are visual identifiers now, so they shouldn't control the margin to the text (which is whitespace). --- functions/icons.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 48396ff5..4ba4811e 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -43,9 +43,9 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 LINUX_ICON $'\UE271' #  SUNOS_ICON $'\U1F31E ' # 🌞 - HOME_ICON $'\UE12C ' #  - FOLDER_ICON $'\UE818 ' #  - NETWORK_ICON $'\UE1AD ' #  + HOME_ICON $'\UE12C' #  + FOLDER_ICON $'\UE818' #  + NETWORK_ICON $'\UE1AD' #  LOAD_ICON $'\UE190 ' #  #RAM_ICON $'\UE87D' #  RAM_ICON $'\UE1E2 ' #  @@ -95,9 +95,9 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 LINUX_ICON $'\UF17C' #  SUNOS_ICON $'\UF185 ' #  - HOME_ICON $'\UF015 ' #  - FOLDER_ICON $'\UF115 ' #  - NETWORK_ICON $'\UF09E ' #  + HOME_ICON $'\UF015' #  + FOLDER_ICON $'\UF115' #  + NETWORK_ICON $'\UF09E' #  LOAD_ICON $'\UF080 ' #  RAM_ICON $'\UF0E4' #  VCS_UNTRACKED_ICON $'\UF059' #  From 4fc59fd57c508ff47871a5efadb4b987b1864702 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 02:36:02 +0100 Subject: [PATCH 17/27] Added the "visual identifier" concept to the `node_version` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a90d18e7..20cba35b 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -550,7 +550,7 @@ prompt_nvm() { [[ -z "${node_version}" ]] && return [[ "$node_version" =~ "$nvm_default" ]] && return - $1_prompt_segment "$0" "green" "011" "${node_version:1} $(print_icon 'NODE_ICON')" + $1_prompt_segment "$0" "green" "011" "${node_version:1}" 'NODE_ICON' } # rbenv information From 409303f45db59aa31cf3df2427d2f6b43d5349e9 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 02:36:57 +0100 Subject: [PATCH 18/27] Added the "visual identifier" concept to the `rbenv` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 20cba35b..b2f36df6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -556,7 +556,7 @@ prompt_nvm() { # rbenv information prompt_rbenv() { if [[ -n "$RBENV_VERSION" ]]; then - "$1_prompt_segment" "$0" "red" "$DEFAULT_COLOR" "$RBENV_VERSION" + "$1_prompt_segment" "$0" "red" "$DEFAULT_COLOR" "$RBENV_VERSION" 'RUBY_ICON' fi } From 056d4ff29ac1dbacc6be0d3b99160a493e47ab1c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 02:43:42 +0100 Subject: [PATCH 19/27] Only check for a user defined variable if we really have an visual identifier. --- powerlevel9k.zsh-theme | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b2f36df6..04e29a2d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -159,12 +159,14 @@ left_prompt_segment() { local visual_identifier if [[ -n $5 ]]; then visual_identifier="$(print_icon $5)" - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $3 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n $4 ]] && visual_identifier="$visual_identifier " + if [[ -n "$visual_identifier" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $3 + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # Add an whitespace if we print more than just the visual identifier + [[ -n $4 ]] && visual_identifier="$visual_identifier " + fi fi echo -n "$visual_identifier%{$fg%}$4$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS" @@ -224,12 +226,14 @@ right_prompt_segment() { local visual_identifier if [[ -n $5 ]]; then visual_identifier="$(print_icon $5)" - # Allow users to overwrite the color for the visual identifier only. - local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR - set_default $visual_identifier_color_variable $3 - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n $4 ]] && visual_identifier=" $visual_identifier" + if [[ -n "$visual_identifier" ]]; then + # Allow users to overwrite the color for the visual identifier only. + local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR + set_default $visual_identifier_color_variable $3 + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + # Add an whitespace if we print more than just the visual identifier + [[ -n $4 ]] && visual_identifier=" $visual_identifier" + fi fi echo -n "$4$visual_identifier$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS%f" From cd5b4d0debac05a74131f06efa918172586865ec Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 15 Dec 2015 03:21:24 +0100 Subject: [PATCH 20/27] Added the "state" concept to the `dir` segment. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 04e29a2d..df11bb5d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -394,9 +394,9 @@ prompt_dir() { local current_icon='' if [[ $(print -P "%~") == '~'* ]]; then - "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_path" 'HOME_ICON' + "$1_prompt_segment" "$0_HOME" "blue" "$DEFAULT_COLOR" "$current_path" 'HOME_ICON' else - "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$current_path" 'FOLDER_ICON' + "$1_prompt_segment" "$0_DEFAULT" "blue" "$DEFAULT_COLOR" "$current_path" 'FOLDER_ICON' fi } From 33d20cb7f24c7af0158152664fd3c73332c78669 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 16 Dec 2015 20:19:50 +0100 Subject: [PATCH 21/27] Added changelog. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c21ea0e..a13ec3ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## v0.3.0 (next) +### Introduced "visual identifiers" to the segments + +Now almost every segment can have a visual identifier, which is an +icon whose color could be adjusted by users. + ### New segment `custom_command` added A new segment that allows users to define a custom command was added. From ffa9336144870a65c9272cb14a1c9e279077ada2 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 16 Dec 2015 20:20:16 +0100 Subject: [PATCH 22/27] Remove trailing whitespaces from CHANGELOG. --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a13ec3ee..a461d2d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ A new segment that allows users to define a custom command was added. ### `virtualenv` changes -This segment now respects `VIRTUAL_ENV_DISABLE_PROMPT`. If this variable is set +This segment now respects `VIRTUAL_ENV_DISABLE_PROMPT`. If this variable is set to `true`, the segments does not get rendered. ### `load` changes @@ -22,7 +22,7 @@ segment is able to show the free ram and used swap. ### `vcs` changes This prompt uses the `VCS_INFO` subsystem by ZSH. From now on this subsystem -is only invoked if a `vcs` segment was configured. +is only invoked if a `vcs` segment was configured. ### `rvm` changes From bd5955221ed2b200853fe8da1aa2ba3b0dc4c5f3 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 16 Dec 2015 22:23:47 +0100 Subject: [PATCH 23/27] Removed trailing whitespace. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a690bfd..cba6a73a 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ To change the way how the current working directory is truncated, just set: # default behaviour is to truncate whole directories In each case you have to specify the length you want to shorten the directory -to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in +to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in others whole directories. ##### ip From b738ba900c5cc4cf5fd116e775062172c72466df Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:17:06 +0100 Subject: [PATCH 24/27] Added the "visual identifiers" concept to the `ram` segment. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index df11bb5d..b3927158 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -520,7 +520,7 @@ prompt_ram() { base=K fi - rendition+="$(print_icon 'RAM_ICON') $(printSizeHumanReadable "$ramfree" $base) " + rendition+="$(printSizeHumanReadable "$ramfree" $base) " ;; swap_used) if [[ "$OS" == "OSX" ]]; then @@ -543,7 +543,7 @@ prompt_ram() { esac done - "$1_prompt_segment" "$0" "yellow" "$DEFAULT_COLOR" "${rendition% }" + "$1_prompt_segment" "$0" "yellow" "$DEFAULT_COLOR" "${rendition% }" 'RAM_ICON' } # Node version from NVM From 045f451e4e8bffc4a684bd5abf156193988e1220 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:22:34 +0100 Subject: [PATCH 25/27] Added the "visual identifier" concept to the `symfony2_tests` and `rspec_stats` segments. --- powerlevel9k.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b3927158..e3cb647a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -580,7 +580,7 @@ prompt_rspec_stats() { code_amount=$(ls -1 app/**/*.rb | wc -l) tests_amount=$(ls -1 spec/**/*.rb | wc -l) - build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "RSpec $(print_icon 'TEST_ICON')" + build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON' fi } @@ -628,7 +628,7 @@ prompt_symfony2_tests() { code_amount=$(ls -1 src/**/*.php | grep -vc Tests) tests_amount=$(ls -1 src/**/*.php | grep -c Tests) - build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "SF2 $(print_icon 'TEST_ICON')" + build_test_stats "$1" "$0" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON' fi } @@ -651,9 +651,9 @@ build_test_stats() { typeset -F 2 ratio local ratio=$(( (tests_amount/code_amount) * 100 )) - (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" - (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" - (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" + (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" + (( ratio < 50 )) && "$1_prompt_segment" "$2_BAD" "red" "$DEFAULT_COLOR" "$headline: $ratio%%" "$6" } # System time From 5cfd800585516ce2251cd4f4cf8f2e1dbadddc70 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 17 Dec 2015 18:24:35 +0100 Subject: [PATCH 26/27] Added the "visual identifier" concept to the `symfony2_version` segment. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index e3cb647a..bf35967a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -637,7 +637,7 @@ prompt_symfony2_version() { if [[ -f app/bootstrap.php.cache ]]; then local symfony2_version symfony2_version=$(grep " VERSION " app/bootstrap.php.cache | sed -e 's/[^.0-9]*//g') - "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$(print_icon 'SYMFONY_ICON') $symfony2_version" + "$1_prompt_segment" "$0" "240" "$DEFAULT_COLOR" "$symfony2_version" 'SYMFONY_ICON' fi } From ac4502ca1fafab54c07d22e4841d8c6c7aeffc95 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 18 Dec 2015 00:47:37 +0100 Subject: [PATCH 27/27] Added the "visual identifier" concept to the `vcs` segment. --- functions/icons.zsh | 8 ++++---- functions/vcs.zsh | 6 ++++++ powerlevel9k.zsh-theme | 11 +++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 4ba4811e..b8e02efd 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -64,8 +64,8 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\UE821 ' #  VCS_BRANCH_ICON $'\UE220' #  VCS_REMOTE_BRANCH_ICON ' '$'\UE804 ' #  - VCS_GIT_ICON $'\UE20E ' #  - VCS_HG_ICON $'\UE1C3 ' #  + VCS_GIT_ICON $'\UE20E ' #  + VCS_HG_ICON $'\UE1C3 ' #  ) ;; 'awesome-fontconfig') @@ -111,8 +111,8 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\UF221 ' #  VCS_BRANCH_ICON $'\UF126' #  VCS_REMOTE_BRANCH_ICON ' '$'\UF204 ' #  - VCS_GIT_ICON $'\UF113 ' #  - VCS_HG_ICON $'\UF0C3 ' #  + VCS_GIT_ICON $'\UF113 ' #  + VCS_HG_ICON $'\UF0C3 ' #  ) ;; *) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index 39d0fdae..49dccc18 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -78,6 +78,12 @@ function +vi-hg-bookmarks() { } function +vi-vcs-detect-changes() { + if [[ "${hook_com[vcs]}" == "git" ]]; then + vcs_visual_identifier='VCS_GIT_ICON' + elif [[ "${hook_com[vcs]}" == "hg" ]]; then + vcs_visual_identifier='VCS_HG_ICON' + fi + if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then VCS_WORKDIR_DIRTY=true else diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bf35967a..5e089521 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -696,8 +696,7 @@ prompt_vcs() { zstyle ':vcs_info:*' check-for-changes true VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%F{$POWERLEVEL9K_VCS_FOREGROUND}%b%c%u%m%f" - zstyle ':vcs_info:git*:*' formats "%F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_GIT_ICON')%f$VCS_DEFAULT_FORMAT" - zstyle ':vcs_info:hg*:*' formats "%F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_HG_ICON')%f$VCS_DEFAULT_FORMAT" + zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT" zstyle ':vcs_info:*' actionformats "%b %F{red}| %a%f" @@ -724,12 +723,12 @@ prompt_vcs() { if [[ -n "$vcs_prompt" ]]; then if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - "$1_prompt_segment" "$0_MODIFIED" "yellow" "$DEFAULT_COLOR" + # $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh, + # as we have there access to vcs_info internal hooks. + "$1_prompt_segment" "$0_MODIFIED" "yellow" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" else - "$1_prompt_segment" "$0" "green" "$DEFAULT_COLOR" + "$1_prompt_segment" "$0" "green" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier" fi - - echo -n "$vcs_prompt " fi }