From 6f5827009fa3a39cc04ab205da2da44965d9a00c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 8 Aug 2018 23:18:36 +0200 Subject: [PATCH 1/3] Fix colors for visual identifiers Make the visual identifier color use numerical color codes as well. This way colors like "purple3" work as visual identifier color. --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6fef6a26..a9b2d1ff 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -172,7 +172,7 @@ left_prompt_segment() { # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR set_default $visual_identifier_color_variable "${foregroundColor}" - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f" fi fi @@ -274,7 +274,7 @@ right_prompt_segment() { # Allow users to overwrite the color for the visual identifier only. local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR set_default $visual_identifier_color_variable "${foregroundColor}" - visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f" + visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f" fi fi From 27fe2c65712a092c8e652fe2c58ac310f69a8e36 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 8 Aug 2018 23:36:40 +0200 Subject: [PATCH 2/3] Make use of helper function in left_end_segment --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a9b2d1ff..781813e7 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -189,7 +189,7 @@ left_prompt_segment() { # End the left prompt, closes the final segment. left_prompt_end() { if [[ -n $CURRENT_BG ]]; then - echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')" + echo -n "%k$(foregroundColor ${CURRENT_BG})$(print_icon 'LEFT_SEGMENT_SEPARATOR')" else echo -n "%k" fi From ef5f9bb1b494bcb1ceb81f7c833750d85701ca4a Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 8 Aug 2018 23:47:01 +0200 Subject: [PATCH 3/3] Fix tests --- 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 ++-- test/segments/laravel_version.spec | 2 +- test/segments/rust_version.spec | 2 +- test/segments/status.spec | 12 ++++++------ 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 2206a9d0..b5b81fc4 100755 --- a/test/powerlevel9k.spec +++ b/test/powerlevel9k.spec @@ -65,7 +65,7 @@ function testDynamicColoringOfVisualIdentifiersWork() { cd /tmp - assertEquals "%K{012} %F{green%}icon-here %f%F{000}/tmp %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{002}icon-here %f%F{000}/tmp %k%F{012}%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{011} %F{green%}icon-here %f%F{009}/tmp %k%F{011}%f " "$(build_left_prompt)" + assertEquals "%K{011} %F{002}icon-here %f%F{009}/tmp %k%F{011}%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{012} %F{000%}icon-here %f%F{000}/tmp %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}icon-here %f%F{000}/tmp %k%F{012}%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 7e060be7..fc6110e4 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{009} %F{226%}Dur %f%F{226}2.03 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}2.03 %k%F{009}%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{009} %F{226%}Dur %f%F{226}0.03 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}0.03 %k%F{009}%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{009} %F{226%}Dur %f%F{226}0.0001 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}0.0001 %k%F{009}%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{009} %F{226%}Dur %f%F{226}23 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}23 %k%F{009}%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{009} %F{226%}Dur %f%F{226}03:00 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}03:00 %k%F{009}%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{009} %F{226%}Dur %f%F{226}02:00:00 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}Dur %f%F{226}02:00:00 %k%F{009}%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 c16e32fc..4e4022b1 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -329,7 +329,7 @@ function testHomeFolderDetectionWorks() { POWERLEVEL9K_HOME_ICON='home-icon' cd ~ - assertEquals "%K{012} %F{000%}home-icon %f%F{000}~ %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}home-icon %f%F{000}~ %k%F{012}%f " "$(build_left_prompt)" cd - unset POWERLEVEL9K_HOME_ICON @@ -341,7 +341,7 @@ function testHomeSubfolderDetectionWorks() { FOLDER=~/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{012} %F{000%}sub-icon %f%F{000}~/powerlevel9k-test %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}sub-icon %f%F{000}~/powerlevel9k-test %k%F{012}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -355,7 +355,7 @@ function testOtherFolderDetectionWorks() { FOLDER=/tmp/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{012} %F{000%}folder-icon %f%F{000}/tmp/powerlevel9k-test %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}folder-icon %f%F{000}/tmp/powerlevel9k-test %k%F{012}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -407,7 +407,7 @@ function testOmittingFirstCharacterWorks() { POWERLEVEL9K_FOLDER_ICON='folder-icon' cd /tmp - assertEquals "%K{012} %F{000%}folder-icon %f%F{000}tmp %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}folder-icon %f%F{000}tmp %k%F{012}%f " "$(build_left_prompt)" cd - unset POWERLEVEL9K_FOLDER_ICON @@ -421,7 +421,7 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() { mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{012} %F{000%}folder-icon %f%F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{012}%f " "$(build_left_prompt)" + assertEquals "%K{012} %F{000}folder-icon %f%F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{012}%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 30b157a5..39be4157 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{002} %F{255%} %f%F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{255} %f%F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)" unset POWERLEVEL9K_GO_ICON unset PWD diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec index 33853a3f..1457558f 100755 --- a/test/segments/kubecontext.spec +++ b/test/segments/kubecontext.spec @@ -69,7 +69,7 @@ function testKubeContext() { alias kubectl=mockKubectl POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{013} %F{015%}⎈ %f%F{015}minikube/default %k%F{013}%f " "$(build_left_prompt)" + assertEquals "%K{013} %F{015}⎈ %f%F{015}minikube/default %k%F{013}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias kubectl @@ -78,7 +78,7 @@ function testKubeContextOtherNamespace() { alias kubectl=mockKubectlOtherNamespace POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext) - assertEquals "%K{013} %F{015%}⎈ %f%F{015}minikube/kube-system %k%F{013}%f " "$(build_left_prompt)" + assertEquals "%K{013} %F{015}⎈ %f%F{015}minikube/kube-system %k%F{013}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias kubectl diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec index ffc11786..b620ce8a 100755 --- a/test/segments/laravel_version.spec +++ b/test/segments/laravel_version.spec @@ -31,7 +31,7 @@ function testLaravelVersionSegment() { POWERLEVEL9K_LARAVEL_ICON='x' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version) - assertEquals "%K{001} %F{015%}x %f%F{015}5.4.23 %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{015}x %f%F{015}5.4.23 %k%F{001}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LARAVEL_ICON diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 7031be87..1317ba85 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -32,7 +32,7 @@ function testRust() { mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{000%}Rust %f%F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{000}Rust %f%F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } diff --git a/test/segments/status.spec b/test/segments/status.spec index fc44275e..8a9b6a1c 100755 --- a/test/segments/status.spec +++ b/test/segments/status.spec @@ -31,7 +31,7 @@ function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() { local POWERLEVEL9K_STATUS_HIDE_SIGNAME=true local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status) - assertEquals "%K{000} %F{002%}✔%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}✔%f %k%F{000}%f " "$(build_left_prompt)" } function testStatusInGeneralErrorCase() { @@ -40,7 +40,7 @@ function testStatusInGeneralErrorCase() { local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false - assertEquals "%K{009} %F{226%}↵ %f%F{226}1 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}↵ %f%F{226}1 %k%F{009}%f " "$(build_left_prompt)" } function testPipestatusInErrorCase() { @@ -50,7 +50,7 @@ function testPipestatusInErrorCase() { local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true - assertEquals "%K{009} %F{226%}↵ %f%F{226}0|0|1|0 %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}↵ %f%F{226}0|0|1|0 %k%F{009}%f " "$(build_left_prompt)" } function testStatusCrossWinsOverVerbose() { @@ -60,7 +60,7 @@ function testStatusCrossWinsOverVerbose() { local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_CROSS=true - assertEquals "%K{000} %F{009%}✘%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{009}✘%f %k%F{000}%f " "$(build_left_prompt)" } function testStatusShowsSignalNameInErrorCase() { @@ -70,7 +70,7 @@ function testStatusShowsSignalNameInErrorCase() { local POWERLEVEL9K_STATUS_VERBOSE=true local POWERLEVEL9K_STATUS_HIDE_SIGNAME=false - assertEquals "%K{009} %F{226%}↵ %f%F{226}SIGILL(4) %k%F{009}%f " "$(build_left_prompt)" + assertEquals "%K{009} %F{226}↵ %f%F{226}SIGILL(4) %k%F{009}%f " "$(build_left_prompt)" } function testStatusSegmentIntegrated() { @@ -79,7 +79,7 @@ function testStatusSegmentIntegrated() { false; powerlevel9k_prepare_prompts - assertEquals "%f%b%k%K{000} %F{009%}✘%f %k%F{000}%f " "${(e)PROMPT}" + assertEquals "%f%b%k%K{000} %F{009}✘%f %k%F{000}%f " "${(e)PROMPT}" } source shunit2/source/2.1/src/shunit2 \ No newline at end of file