From c36b47b00780cf680f2133782124dcbaab5eb9a0 Mon Sep 17 00:00:00 2001 From: Kevin Chandler Date: Tue, 24 Apr 2018 16:07:20 -0700 Subject: [PATCH 1/4] Update default public ip file name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47a62c95..7a6dd49c 100644 --- a/README.md +++ b/README.md @@ -481,7 +481,7 @@ segment will not be displayed. | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| +|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p9k_public_ip'|This is the file your public IP is cached in.| |`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| |`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| |`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.| From 2f95fd04d94a5b2fed33f17ecd1c1d7bab5ad44a Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 1 Jun 2018 11:49:23 -0400 Subject: [PATCH 2/4] Fix icons cut off in some terminal emulators --- powerlevel9k.zsh-theme | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0e09ef03..836d4ae0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -156,12 +156,12 @@ left_prompt_segment() { if [[ -n $6 ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then + # Add an whitespace if we print more than just the visual identifier + [[ -n "$5" ]] && visual_identifier="$visual_identifier " # 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 $4 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier="$visual_identifier " fi fi @@ -240,12 +240,12 @@ right_prompt_segment() { if [[ -n "$6" ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then + # Add an whitespace if we print more than just the visual identifier + [[ -n "$5" ]] && visual_identifier=" $visual_identifier" # 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 $4 visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" - # Add an whitespace if we print more than just the visual identifier - [[ -n "$5" ]] && visual_identifier=" $visual_identifier" fi fi From 5e0b92434660ed73894b41a8a586c22c30830552 Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 1 Jun 2018 13:34:52 -0400 Subject: [PATCH 3/4] Update unit tests for fixing icons cut off --- test/powerlevel9k.spec | 6 +++--- test/segments/command_execution_time.spec | 12 ++++++------ test/segments/dir.spec | 10 +++++----- test/segments/go_version.spec | 2 +- test/segments/kubecontext.spec | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 5f6b6f27..99b3ea17 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -65,7 +65,7 @@ function testDynamicColoringOfVisualIdentifiersWork() { cd /tmp - assertEquals "%K{blue} %F{green%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{green%}icon-here %f%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR @@ -86,7 +86,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { cd /tmp - assertEquals "%K{yellow} %F{green%}icon-here%f %F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)" + assertEquals "%K{yellow} %F{green%}icon-here %f%F{red}/tmp %k%F{yellow}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_COLOR @@ -106,7 +106,7 @@ function testOverwritingIconsWork() { #cd ~/$testFolder cd /tmp - assertEquals "%K{blue} %F{black%}icon-here%f %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}icon-here %f%F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_DIR_FOLDER_ICON diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec index 09738859..66d2dc1d 100755 --- a/test/segments/command_execution_time.spec +++ b/test/segments/command_execution_time.spec @@ -28,7 +28,7 @@ function testCommandExecutionTimeThresholdCouldBeChanged() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1 _P9K_COMMAND_DURATION=2.03 - assertEquals "%K{red} %F{226%}Dur%f %F{226}2.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}2.03 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -40,7 +40,7 @@ function testCommandExecutionTimeThresholdCouldBeSetToZero() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 _P9K_COMMAND_DURATION=0.03 - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}0.03 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -53,7 +53,7 @@ function testCommandExecutionTimePrecisionCouldBeChanged() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4 _P9K_COMMAND_DURATION=0.0001 - assertEquals "%K{red} %F{226%}Dur%f %F{226}0.0001 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}0.0001 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -66,7 +66,7 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() { POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 _P9K_COMMAND_DURATION=23.5001 - assertEquals "%K{red} %F{226%}Dur%f %F{226}23 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}23 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -77,7 +77,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=180 - assertEquals "%K{red} %F{226%}Dur%f %F{226}03:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}03:00 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION @@ -87,7 +87,7 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time) _P9K_COMMAND_DURATION=7200 - assertEquals "%K{red} %F{226%}Dur%f %F{226}02:00:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{226%}Dur %f%F{226}02:00:00 %k%F{red}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset _P9K_COMMAND_DURATION diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 97bc857c..fdaf6a31 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -265,7 +265,7 @@ function testHomeFolderDetectionWorks() { POWERLEVEL9K_HOME_ICON='home-icon' cd ~ - assertEquals "%K{blue} %F{black%}home-icon%f %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%f " "$(build_left_prompt)" cd - unset POWERLEVEL9K_HOME_ICON @@ -277,7 +277,7 @@ function testHomeSubfolderDetectionWorks() { FOLDER=~/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}sub-icon%f %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}sub-icon %f%F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -291,7 +291,7 @@ function testOtherFolderDetectionWorks() { FOLDER=/tmp/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -343,7 +343,7 @@ function testOmittingFirstCharacterWorks() { POWERLEVEL9K_FOLDER_ICON='folder-icon' cd /tmp - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" cd - unset POWERLEVEL9K_FOLDER_ICON @@ -357,7 +357,7 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() { mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black%}folder-icon%f %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec index 2aac460b..b434dce5 100755 --- a/test/segments/go_version.spec +++ b/test/segments/go_version.spec @@ -40,7 +40,7 @@ function testGo() { PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k" - assertEquals "%K{green} %F{255%}%f %F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{255%} %f%F{255}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" unset POWERLEVEL9K_GO_ICON unset PWD diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index eaaa2300..abcfec07 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -51,7 +51,7 @@ function testKubeContext() { alias kubectl=mockKubectl POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias kubectl @@ -60,7 +60,7 @@ function testKubeContextOtherNamespace() { alias kubectl=mockKubectlOtherNamespace POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias kubectl From 9c4203bdf80440b43b5f559b5d8856f6b817ad9e Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 1 Jun 2018 14:18:18 -0400 Subject: [PATCH 4/4] Add comments about the whitespace and coloring --- powerlevel9k.zsh-theme | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 836d4ae0..b8d4b0cc 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -156,7 +156,9 @@ left_prompt_segment() { if [[ -n $6 ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then - # Add an whitespace if we print more than just the visual identifier + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. [[ -n "$5" ]] && visual_identifier="$visual_identifier " # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR @@ -240,7 +242,9 @@ right_prompt_segment() { if [[ -n "$6" ]]; then visual_identifier="$(print_icon $6)" if [[ -n "$visual_identifier" ]]; then - # Add an whitespace if we print more than just the visual identifier + # Add an whitespace if we print more than just the visual identifier. + # To avoid cutting off the visual identifier in some terminal emulators (e.g., Konsole, st), + # we need to color both the visual identifier and the whitespace. [[ -n "$5" ]] && visual_identifier=" $visual_identifier" # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR