From 877ef6177366ffdcb25dcb6dfac38eb899e2f4e4 Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Wed, 22 Aug 2018 14:37:52 -0400 Subject: [PATCH 01/25] Fix icons cut off in RPROMPT segments --- powerlevel9k.zsh-theme | 4 ++-- 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 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0b2287ef..1e9d1123 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -163,7 +163,7 @@ left_prompt_segment() { # 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" + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier" fi fi @@ -256,7 +256,7 @@ right_prompt_segment() { # 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" + visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier" fi fi diff --git a/test/powerlevel9k.spec b/test/powerlevel9k.spec index 0ddf36c1..75df29f8 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{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{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{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 d3588d83..7ad2cb5c 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{yellow1%}Dur %f%F{yellow1}2.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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{yellow1%}Dur %f%F{yellow1}0.03 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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{yellow1%}Dur %f%F{yellow1}0.0001 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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{yellow1%}Dur %f%F{yellow1}23 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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{yellow1%}Dur %f%F{yellow1}03:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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{yellow1%}Dur %f%F{yellow1}02:00:00 %k%F{red}%f " "$(build_left_prompt)" + assertEquals "%K{red} %F{yellow1%}Dur %F{yellow1}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 b5fce59f..04601622 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{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{blue} %F{black%}home-icon %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" cd - unset POWERLEVEL9K_HOME_ICON @@ -341,7 +341,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{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -355,7 +355,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{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER @@ -407,7 +407,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{black}tmp %k%F{blue}%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{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{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 9104ac8b..d8982e21 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{grey93%} %f%F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)" + assertEquals "%K{green} %F{grey93%} %F{grey93}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 63810378..5e8bbe82 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{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈ %F{white}minikube/default %k%F{magenta}%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{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" + assertEquals "%K{magenta} %F{white%}⎈ %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias kubectl From 24bbbfc9bdbdc0666a53cd4a60a8b57551e9f0ca Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Wed, 22 Aug 2018 15:01:04 -0400 Subject: [PATCH 02/25] Update unit tests for fixing RPROMPT icons cut off --- test/segments/laravel_version.spec | 2 +- test/segments/rust_version.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec index 6133b19a..34b06cce 100755 --- a/test/segments/laravel_version.spec +++ b/test/segments/laravel_version.spec @@ -32,7 +32,7 @@ function testLaravelVersionSegment() { POWERLEVEL9K_LARAVEL_ICON='x' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version) - assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{white%}x %F{white}5.4.23 %k%F{maroon}%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 34883a10..091d5217 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{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black%}Rust %F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } From 735994f82ea47118aa31278af1c9a596d35469ed Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Fri, 7 Sep 2018 11:52:21 +0200 Subject: [PATCH 03/25] Fix for #974 --- functions/utilities.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 127007fb..cedf5493 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -102,7 +102,9 @@ case $(uname) in ;; Linux) OS='Linux' - os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + if [ -f /etc/os-release ]; then + os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + fi case "$os_release_id" in *arch*) OS_ICON=$(print_icon 'LINUX_ARCH_ICON') From 5737ca6e81a3191cb232085877b5894be0a052ed Mon Sep 17 00:00:00 2001 From: Yang Tang Date: Fri, 12 Oct 2018 14:09:22 -0400 Subject: [PATCH 04/25] Remove extra %f in unit tests --- test/core/color_overriding.spec | 10 +++++----- test/core/visual_identifier.spec | 8 ++++---- test/segments/anaconda.spec | 6 +++--- test/segments/aws_eb_env.spec | 4 ++-- test/segments/background_jobs.spec | 6 +++--- test/segments/battery.spec | 26 +++++++++++++------------- test/segments/custom.spec | 4 ++-- test/segments/disk_usage.spec | 10 +++++----- test/segments/ip.spec | 12 ++++++------ test/segments/load.spec | 12 ++++++------ test/segments/node_version.spec | 2 +- test/segments/nodeenv.spec | 4 ++-- test/segments/nvm.spec | 2 +- test/segments/ram.spec | 6 +++--- test/segments/ssh.spec | 6 +++--- test/segments/status.spec | 12 ++++++------ test/segments/swap.spec | 4 ++-- test/segments/swift_version.spec | 2 +- test/segments/todo.spec | 2 +- test/segments/vcs-git.spec | 8 ++++---- test/segments/vcs-hg.spec | 2 +- 21 files changed, 74 insertions(+), 74 deletions(-) diff --git a/test/core/color_overriding.spec b/test/core/color_overriding.spec index f2c3d891..e23d3aaa 100755 --- a/test/core/color_overriding.spec +++ b/test/core/color_overriding.spec @@ -16,7 +16,7 @@ function testDynamicColoringOfSegmentsWork() { local POWERLEVEL9K_DATE_ICON="date-icon" local POWERLEVEL9K_DATE_BACKGROUND='red' - assertEquals "%K{001} %F{000}date-icon %f%F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{000}date-icon %F{000}%D{%d.%m.%y} %k%F{001}%f " "$(build_left_prompt)" } function testDynamicColoringOfVisualIdentifiersWork() { @@ -24,7 +24,7 @@ function testDynamicColoringOfVisualIdentifiersWork() { local POWERLEVEL9K_DATE_ICON="date-icon" local POWERLEVEL9K_DATE_VISUAL_IDENTIFIER_COLOR='green' - assertEquals "%K{007} %F{002}date-icon %f%F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{002}date-icon %F{000}%D{%d.%m.%y} %k%F{007}%f " "$(build_left_prompt)" } function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { @@ -34,7 +34,7 @@ function testColoringOfVisualIdentifiersDoesNotOverwriteColoringOfSegment() { local POWERLEVEL9K_DATE_FOREGROUND='red' local POWERLEVEL9K_DATE_BACKGROUND='yellow' - assertEquals "%K{003} %F{002}date-icon %f%F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)" + assertEquals "%K{003} %F{002}date-icon %F{001}%D{%d.%m.%y} %k%F{003}%f " "$(build_left_prompt)" } function testColorOverridingOfStatefulSegment() { @@ -45,7 +45,7 @@ function testColorOverridingOfStatefulSegment() { # Provoke state local SSH_CLIENT="x" - assertEquals "%K{001} %F{002}ssh-icon %f%F{002}%m %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{002}ssh-icon %F{002}%m %k%F{001}%f " "$(build_left_prompt)" } function testColorOverridingOfCustomSegment() { @@ -56,7 +56,7 @@ function testColorOverridingOfCustomSegment() { local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND='red' local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND='red' - assertEquals "%K{001} %F{002}CW %f%F{001}world %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{002}CW %F{001}world %k%F{001}%f " "$(build_left_prompt)" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/core/visual_identifier.spec b/test/core/visual_identifier.spec index c6c6bef5..33815f79 100755 --- a/test/core/visual_identifier.spec +++ b/test/core/visual_identifier.spec @@ -18,7 +18,7 @@ function testOverwritingIconsWork() { local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' - assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)" } function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() { @@ -27,7 +27,7 @@ function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() { local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' - assertEquals "%K{007} %F{000}icon-here %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{000}icon-here %F{000}world1 %k%F{007}%f " "$(build_left_prompt)" } function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() { @@ -36,7 +36,7 @@ function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() { local POWERLEVEL9K_CUSTOM_WORLD1='echo world1' local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here' - assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%f%E" "$(build_right_prompt)" + assertEquals "%F{007}%f%K{007}%F{000} world1%F{000} icon-here%E" "$(build_right_prompt)" } function testVisualIdentifierPrintsNothingIfNotAvailable() { @@ -54,7 +54,7 @@ function testVisualIdentifierIsPrintedInNumericalColorCode() { local POWERLEVEL9K_CUSTOM_WORLD1_ICON="xxx" local POWERLEVEL9K_CUSTOM_WORLD1_VISUAL_IDENTIFIER_COLOR="purple3" - assertEquals "%K{007} %F{056}xxx %f%F{000}world1 %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{056}xxx %F{000}world1 %k%F{007}%f " "$(build_left_prompt)" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/anaconda.spec b/test/segments/anaconda.spec index efcfc030..a25aed9b 100755 --- a/test/segments/anaconda.spec +++ b/test/segments/anaconda.spec @@ -35,7 +35,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() { CONDA_ENV_PATH=/tmp unset CONDA_PREFIX - assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)" } function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() { @@ -49,7 +49,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() { unset CONDA_ENV_PATH local CONDA_PREFIX="test" - assertEquals "%K{004} %F{000}icon-here %f%F{000}(test) %k%F{004}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(build_left_prompt)" } function testAnacondaSegmentWorks() { @@ -63,7 +63,7 @@ function testAnacondaSegmentWorks() { local CONDA_ENV_PATH=/tmp local CONDA_PREFIX="test" - assertEquals "%K{004} %F{000}icon-here %f%F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/aws_eb_env.spec b/test/segments/aws_eb_env.spec index 99b418e0..6cd8931c 100755 --- a/test/segments/aws_eb_env.spec +++ b/test/segments/aws_eb_env.spec @@ -31,7 +31,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() { echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml cd /tmp/powerlevel9k-test - assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)" rm -fr /tmp/powerlevel9k-test cd - @@ -52,7 +52,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml cd /tmp/powerlevel9k-test/1/12/123/1234/12345 - assertEquals "%K{000} %F{002}🌱 %f%F{002}test %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)" rm -fr /tmp/powerlevel9k-test cd - diff --git a/test/segments/background_jobs.spec b/test/segments/background_jobs.spec index 3d83e171..558ad1aa 100755 --- a/test/segments/background_jobs.spec +++ b/test/segments/background_jobs.spec @@ -34,7 +34,7 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)" unfunction jobs } @@ -52,7 +52,7 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{006}⚙%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)" unfunction jobs } @@ -70,7 +70,7 @@ function testBackgroundJobsSegmentWithVerboseMode() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{006}⚙ %f%F{006}3 %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{006}⚙ %F{006}3 %k%F{000}%f " "$(build_left_prompt)" unfunction jobs } diff --git a/test/segments/battery.spec b/test/segments/battery.spec index 79e25d6f..39437b7f 100755 --- a/test/segments/battery.spec +++ b/test/segments/battery.spec @@ -69,7 +69,7 @@ function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() { makeBatterySay "Now drawing from 'Battery Power' -InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true" - assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{001}🔋 %F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() { @@ -77,7 +77,7 @@ function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() { makeBatterySay "Now drawing from 'Battery Power' -InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true" - assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{003}🔋 %F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() { @@ -85,7 +85,7 @@ function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() { makeBatterySay "Now drawing from 'Battery Power' -InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true" - assertEquals "%K{000} %F{007}🔋 %f%F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{007}🔋 %F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() { @@ -93,7 +93,7 @@ function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() { makeBatterySay "Now drawing from 'Battery Power' -InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true" - assertEquals "%K{000} %F{003}🔋 %f%F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{003}🔋 %F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsFullOnOSX() { @@ -101,7 +101,7 @@ function testBatterySegmentIfBatteryIsFullOnOSX() { makeBatterySay "Now drawing from 'AC Power' -InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true" - assertEquals "%K{000} %F{002}🔋 %f%F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{002}🔋 %F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsCalculatingOnOSX() { @@ -109,42 +109,42 @@ function testBatterySegmentIfBatteryIsCalculatingOnOSX() { makeBatterySay "Now drawing from 'Battery Power' -InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true" - assertEquals "%K{000} %F{007}🔋 %f%F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{007}🔋 %F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() { local OS='Linux' # Fake Linux makeBatterySay "4" "Discharging" - assertEquals "%K{000} %F{001}🔋 %f%F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{001}🔋 %F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() { local OS='Linux' # Fake Linux makeBatterySay "4" "Charging" - assertEquals "%K{000} %F{003}🔋 %f%F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{003}🔋 %F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() { local OS='Linux' # Fake Linux makeBatterySay "10" "Discharging" - assertEquals "%K{000} %F{007}🔋 %f%F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{007}🔋 %F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() { local OS='Linux' # Fake Linux makeBatterySay "10" "Charging" - assertEquals "%K{000} %F{003}🔋 %f%F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{003}🔋 %F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsFullOnLinux() { local OS='Linux' # Fake Linux makeBatterySay "100" "Full" - assertEquals "%K{000} %F{002}🔋 %f%F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{002}🔋 %F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})" } function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() { @@ -155,7 +155,7 @@ function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() { # For running on Mac, we need to mock date :( [[ -f /usr/local/bin/gdate ]] && alias date=gdate - assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{007}🔋 %F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})" unalias date &>/dev/null # unaliasing date fails where it was never aliased (e.g. on Linux). @@ -171,7 +171,7 @@ function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() { echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi chmod +x ${FOLDER}/usr/bin/acpi - assertEquals "%K{000} %F{007}🔋 %f%F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})" + assertEquals "%K{000} %F{007}🔋 %F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/custom.spec b/test/segments/custom.spec index 0f66c82f..7aef02b0 100755 --- a/test/segments/custom.spec +++ b/test/segments/custom.spec @@ -67,7 +67,7 @@ function testSettingVisualIdentifierForCustomSegment() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{007} %F{000}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{000}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)" } function testSettingVisualIdentifierForegroundColorForCustomSegment() { @@ -80,7 +80,7 @@ function testSettingVisualIdentifierForegroundColorForCustomSegment() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{007} %F{001}hw %f%F{000}world %k%F{007}%f " "$(build_left_prompt)" + assertEquals "%K{007} %F{001}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/disk_usage.spec b/test/segments/disk_usage.spec index ebafe31d..7858da4f 100755 --- a/test/segments/disk_usage.spec +++ b/test/segments/disk_usage.spec @@ -40,7 +40,7 @@ function testDiskUsageSegmentWhenDiskIsAlmostFull() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{001} %F{007}hdd %f%F{007}97%% %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{007}hdd %F{007}97%% %k%F{001}%f " "$(build_left_prompt)" unfunction df } @@ -56,7 +56,7 @@ function testDiskUsageSegmentWhenDiskIsVeryFull() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{003} %F{000}hdd %f%F{000}94%% %k%F{003}%f " "$(build_left_prompt)" + assertEquals "%K{003} %F{000}hdd %F{000}94%% %k%F{003}%f " "$(build_left_prompt)" unfunction df } @@ -72,7 +72,7 @@ function testDiskUsageSegmentWhenDiskIsQuiteEmpty() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{000} %F{003}hdd %f%F{003}4%% %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{003}hdd %F{003}4%% %k%F{000}%f " "$(build_left_prompt)" unfunction df } @@ -105,7 +105,7 @@ function testDiskUsageSegmentWarningLevelCouldBeAdjusted() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{003} %F{000}hdd %f%F{000}11%% %k%F{003}%f " "$(build_left_prompt)" + assertEquals "%K{003} %F{000}hdd %F{000}11%% %k%F{003}%f " "$(build_left_prompt)" unfunction df } @@ -123,7 +123,7 @@ function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{001} %F{007}hdd %f%F{007}11%% %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{007}hdd %F{007}11%% %k%F{001}%f " "$(build_left_prompt)" unfunction df } diff --git a/test/segments/ip.spec b/test/segments/ip.spec index 254f11c9..cd9f727d 100755 --- a/test/segments/ip.spec +++ b/test/segments/ip.spec @@ -68,7 +68,7 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() { source powerlevel9k.zsh-theme local OS='OSX' # Fake OSX - assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" unalias ipconfig unalias networksetup @@ -123,7 +123,7 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() { source powerlevel9k.zsh-theme local OS='OSX' # Fake OSX - assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" unfunction ipconfig unalias networksetup @@ -139,7 +139,7 @@ function testIpSegmentWorksOnOsxWithInterfaceSpecified() { source powerlevel9k.zsh-theme local OS='OSX' # Fake OSX - assertEquals "%K{006} %F{000}IP %f%F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)" unalias ipconfig } @@ -169,7 +169,7 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() { source powerlevel9k.zsh-theme local OS='Linux' # Fake Linux - assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" unfunction ip } @@ -204,7 +204,7 @@ function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() { source powerlevel9k.zsh-theme local OS='Linux' # Fake Linux - assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" unfunction ip } @@ -223,7 +223,7 @@ inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 source powerlevel9k.zsh-theme local OS='Linux' # Fake Linux - assertEquals "%K{006} %F{000}IP %f%F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" + assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)" unfunction ip } diff --git a/test/segments/load.spec b/test/segments/load.spec index 0f8ee332..5867b419 100755 --- a/test/segments/load.spec +++ b/test/segments/load.spec @@ -42,7 +42,7 @@ function testLoadSegmentWorksOnOsx() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="OSX" # Fake OSX - assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" unfunction sysctl } @@ -64,7 +64,7 @@ function testLoadSegmentWorksOnBsd() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="BSD" # Fake BSD - assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" unfunction sysctl } @@ -81,7 +81,7 @@ function testLoadSegmentWorksOnLinux() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{002} %F{000}L %f%F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})" unalias nproc } @@ -101,7 +101,7 @@ function testLoadSegmentNormalState() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{002} %F{000}L %f%F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{002} %F{000}L %F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})" unalias nproc } @@ -121,7 +121,7 @@ function testLoadSegmentWarningState() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{003} %F{000}L %f%F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}L %F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})" unalias nproc } @@ -141,7 +141,7 @@ function testLoadSegmentCriticalState() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{001} %F{000}L %f%F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})" + assertEquals "%K{001} %F{000}L %F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})" unalias nproc } diff --git a/test/segments/node_version.spec b/test/segments/node_version.spec index 69b9cbb7..764bfda2 100755 --- a/test/segments/node_version.spec +++ b/test/segments/node_version.spec @@ -33,7 +33,7 @@ function testNodeVersionSegmentWorks() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{002} %F{007}⬢ %f%F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{007}⬢ %F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)" unfunction node } diff --git a/test/segments/nodeenv.spec b/test/segments/nodeenv.spec index 2e9d779e..3764f1f0 100755 --- a/test/segments/nodeenv.spec +++ b/test/segments/nodeenv.spec @@ -73,7 +73,7 @@ function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{002}⬢ %f%F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}⬢ %F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)" unset NODE_VIRTUAL_ENV unalias node @@ -90,7 +90,7 @@ function testNodeenvSegmentWorks() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{002}⬢ %f%F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}⬢ %F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)" unfunction node unset NODE_VIRTUAL_ENV diff --git a/test/segments/nvm.spec b/test/segments/nvm.spec index c9ed430d..b53bf22e 100755 --- a/test/segments/nvm.spec +++ b/test/segments/nvm.spec @@ -51,7 +51,7 @@ function testNvmSegmentWorksWithoutHavingADefaultAlias() { [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0' } - assertEquals "%K{005} %F{000}⬢ %f%F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)" + assertEquals "%K{005} %F{000}⬢ %F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)" } function testNvmSegmentPrintsNothingWhenOnDefaultVersion() { diff --git a/test/segments/ram.spec b/test/segments/ram.spec index 2c9f1693..292c784b 100755 --- a/test/segments/ram.spec +++ b/test/segments/ram.spec @@ -36,7 +36,7 @@ Pages inactive: 1313411. source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="OSX" # Fake OSX - assertEquals "%K{003} %F{000}RAM %f%F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}RAM %F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})" unalias vm_stat } @@ -49,7 +49,7 @@ function testRamSegmentWorksOnBsd() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="BSD" # Fake BSD - assertEquals "%K{003} %F{000}RAM %f%F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}RAM %F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})" } function testRamSegmentWorksOnLinux() { @@ -60,7 +60,7 @@ function testRamSegmentWorksOnLinux() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{003} %F{000}RAM %f%F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}RAM %F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/ssh.spec b/test/segments/ssh.spec index 3245231f..40723ebd 100755 --- a/test/segments/ssh.spec +++ b/test/segments/ssh.spec @@ -37,7 +37,7 @@ function testSshSegmentWorksIfOnlySshClientIsSet() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)" unset SSH_CLIENT } @@ -54,7 +54,7 @@ function testSshSegmentWorksIfOnlySshTtyIsSet() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)" unset SSH_TTY } @@ -71,7 +71,7 @@ function testSshSegmentWorksIfAllNecessaryVariablesAreSet() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{003}ssh-icon%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)" unset SSH_TTY unset SSH_CLIENT diff --git a/test/segments/status.spec b/test/segments/status.spec index 9fb34e09..839f30ab 100755 --- a/test/segments/status.spec +++ b/test/segments/status.spec @@ -37,7 +37,7 @@ function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() { # Load Powerlevel9k source powerlevel9k.zsh-theme - assertEquals "%K{000} %F{002}✔%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{002}✔ %k%F{000}%f " "$(build_left_prompt)" } function testStatusInGeneralErrorCase() { @@ -50,7 +50,7 @@ function testStatusInGeneralErrorCase() { source powerlevel9k.zsh-theme local RETVAL=1 - assertEquals "%K{001} %F{226}↵ %f%F{226}1 %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{226}↵ %F{226}1 %k%F{001}%f " "$(build_left_prompt)" } function testPipestatusInErrorCase() { @@ -64,7 +64,7 @@ function testPipestatusInErrorCase() { local -a RETVALS RETVALS=(0 0 1 0) - assertEquals "%K{001} %F{226}↵ %f%F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{226}↵ %F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)" } function testStatusCrossWinsOverVerbose() { @@ -78,7 +78,7 @@ function testStatusCrossWinsOverVerbose() { source powerlevel9k.zsh-theme local RETVAL=1 - assertEquals "%K{000} %F{001}✘%f %k%F{000}%f " "$(build_left_prompt)" + assertEquals "%K{000} %F{001}✘ %k%F{000}%f " "$(build_left_prompt)" } function testStatusShowsSignalNameInErrorCase() { @@ -92,7 +92,7 @@ function testStatusShowsSignalNameInErrorCase() { source powerlevel9k.zsh-theme local RETVAL=132 - assertEquals "%K{001} %F{226}↵ %f%F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{226}↵ %F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)" } function testStatusSegmentIntegrated() { @@ -107,7 +107,7 @@ function testStatusSegmentIntegrated() { false; powerlevel9k_prepare_prompts - assertEquals "%f%b%k%K{000} %F{001}✘%f %k%F{000}%f " "${(e)PROMPT}" + assertEquals "%f%b%k%K{000} %F{001}✘ %k%F{000}%f " "${(e)PROMPT}" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/swap.spec b/test/segments/swap.spec index 7db5416b..07b254be 100755 --- a/test/segments/swap.spec +++ b/test/segments/swap.spec @@ -36,7 +36,7 @@ function testSwapSegmentWorksOnOsx() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="OSX" # Fake OSX - assertEquals "%K{003} %F{000}SWP %f%F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}SWP %F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})" unfunction sysctl } @@ -52,7 +52,7 @@ function testSwapSegmentWorksOnLinux() { source ${P9K_HOME}/powerlevel9k.zsh-theme local OS="Linux" # Fake Linux - assertEquals "%K{003} %F{000}SWP %f%F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})" + assertEquals "%K{003} %F{000}SWP %F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/swift_version.spec b/test/segments/swift_version.spec index 47fc0b7f..57a2ef7b 100755 --- a/test/segments/swift_version.spec +++ b/test/segments/swift_version.spec @@ -49,7 +49,7 @@ function testSwiftSegmentWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{005} %F{007}Swift %f%F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)" + assertEquals "%K{005} %F{007}Swift %F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)" unfunction swift } diff --git a/test/segments/todo.spec b/test/segments/todo.spec index 875c45f8..21da2a92 100755 --- a/test/segments/todo.spec +++ b/test/segments/todo.spec @@ -52,7 +52,7 @@ function testTodoSegmentWorksAsExpected() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{244} %F{000}☑ %f%F{000}100 %k%F{244}%f " "$(build_left_prompt)" + assertEquals "%K{244} %F{000}☑ %F{000}100 %k%F{244}%f " "$(build_left_prompt)" } source shunit2/shunit2 \ No newline at end of file diff --git a/test/segments/vcs-git.spec b/test/segments/vcs-git.spec index bddecf6c..3c694d12 100755 --- a/test/segments/vcs-git.spec +++ b/test/segments/vcs-git.spec @@ -117,7 +117,7 @@ function testGitIconWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{002} %F{000}Git-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{000}Git-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)" } function testGitlabIconWorks() { @@ -132,7 +132,7 @@ function testGitlabIconWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{002} %F{000}GL-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{000}GL-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)" } function testBitbucketIconWorks() { @@ -147,7 +147,7 @@ function testBitbucketIconWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{002} %F{000}BB-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{000}BB-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)" } function testGitHubIconWorks() { @@ -162,7 +162,7 @@ function testGitHubIconWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{002} %F{000}GH-Icon %f%F{000} master %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{000}GH-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)" } function testUntrackedFilesIconWorks() { diff --git a/test/segments/vcs-hg.spec b/test/segments/vcs-hg.spec index 2903f544..506bc078 100755 --- a/test/segments/vcs-hg.spec +++ b/test/segments/vcs-hg.spec @@ -189,7 +189,7 @@ function testMercurialIconWorks() { # Load Powerlevel9k source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{002} %F{000}HG-Icon %f%F{000} default %k%F{002}%f " "$(build_left_prompt)" + assertEquals "%K{002} %F{000}HG-Icon %F{000} default %k%F{002}%f " "$(build_left_prompt)" } function testBookmarkIconWorks() { From a8db401808f6daf16710118bd7fb37f6b30b261a Mon Sep 17 00:00:00 2001 From: Ymage Date: Thu, 3 Jan 2019 12:07:27 +0100 Subject: [PATCH 05/25] [Bugfix] virtualenv prompt displaying Fix #1127 --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 79237385..7077bfc8 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1648,7 +1648,7 @@ prompt_vi_mode() { # https://virtualenv.pypa.io/en/latest/ prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" - if [[ -n "$virtualenv_path" && -z "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then + if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' fi } From 12e972486055dbb37279ef81ae4d2114e8221f19 Mon Sep 17 00:00:00 2001 From: Ymage Date: Mon, 7 Jan 2019 09:18:34 +0100 Subject: [PATCH 06/25] Merge with @dritter proposal --- powerlevel9k.zsh-theme | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7077bfc8..472dd949 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1648,7 +1648,12 @@ prompt_vi_mode() { # https://virtualenv.pypa.io/en/latest/ prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" - if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then + + # Early exit; $virtualenv_path must always be set. + [[ -z "$virtualenv_path" ]] && return + + # Check if VIRTUAL_ENV_DISABLE_PROMPT is set to false, or is a numerical value + if [[ "$VIRTUAL_ENV_DISABLE_PROMPT" == "false" ]] || (( VIRTUAL_ENV_DISABLE_PROMPT )); then "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' fi } From ee7416962d80dfaaed7efd57511d5aa568480d21 Mon Sep 17 00:00:00 2001 From: Ymage Date: Wed, 9 Jan 2019 17:00:05 +0100 Subject: [PATCH 07/25] Remove $VIRTUAL_ENV_DISABLE_PROMPT testing --- powerlevel9k.zsh-theme | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 472dd949..60c16b5a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1652,10 +1652,7 @@ prompt_virtualenv() { # Early exit; $virtualenv_path must always be set. [[ -z "$virtualenv_path" ]] && return - # Check if VIRTUAL_ENV_DISABLE_PROMPT is set to false, or is a numerical value - if [[ "$VIRTUAL_ENV_DISABLE_PROMPT" == "false" ]] || (( VIRTUAL_ENV_DISABLE_PROMPT )); then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' - fi + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' } ################################################################ From 8b4bed99df95cfc3e3ad80f500098bab1c9cdb7b Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 23 Jan 2019 22:37:45 +0100 Subject: [PATCH 08/25] Add documentation about VIRTUAL_ENV_DISABLE_PROMPT #1128 --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebcdd454..33d787bb 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ The segments that are currently available are: * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * **Python Segments:** - * `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). + * [`virtualenv`](#virtualenv) - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). * [`anaconda`](#anaconda) - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment. * `pyenv` - Your active python version as reported by the first word of [`pyenv version`](https://github.com/yyuu/pyenv). Note that the segment is not displayed if that word is _system_ i.e. the segment is inactive if you are using system python. * **Ruby Segments:** @@ -725,6 +725,12 @@ you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-L To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''` +##### virtualenv + +This segment shows your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). To avoid +VirtualEnvs activate command from interfering with Powerlevel9k, you should set +`VIRTUAL_ENV_DISABLE_PROMPT=1` in your `~/.zshrc`. + #### Unit Test Ratios The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" From 081000c49e3792a9d2877344650011a7b38a30c3 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 23 Jan 2019 22:47:10 +0100 Subject: [PATCH 09/25] Replace call to basename with ZSH internals #1128 --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 60c16b5a..383a3b91 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1652,7 +1652,7 @@ prompt_virtualenv() { # Early exit; $virtualenv_path must always be set. [[ -z "$virtualenv_path" ]] && return - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" 'PYTHON_ICON' + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "${virtualenv_path:t}" 'PYTHON_ICON' } ################################################################ From 938b0d49a13c2d69181595234e9eda4d72049396 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 23 Jan 2019 23:11:01 +0100 Subject: [PATCH 10/25] Avoid externals when parsing the os release on linux --- functions/utilities.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index cedf5493..95f89d99 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -103,7 +103,7 @@ case $(uname) in Linux) OS='Linux' if [ -f /etc/os-release ]; then - os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + [[ ${(f)"$((/dev/null)"} =~ "ID=([A-Za-z]+)" ]] && os_release_id="${match[1]}" fi case "$os_release_id" in *arch*) From 1a1572669ce946a095bc27d3d7b175ba83fab7b5 Mon Sep 17 00:00:00 2001 From: Ythildir Date: Thu, 6 Sep 2018 20:30:24 +0200 Subject: [PATCH 11/25] Fix white arrow on newline --- powerlevel9k.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 383a3b91..4f2caae5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -364,6 +364,7 @@ prompt_newline() { "$0" \ "$2" \ "NONE" "NONE" "${newline}" + CURRENT_BG='NONE' POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws } From 020287dd75343e1afca4ee3c87398a0ea08d3a6f Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 1 Feb 2019 11:01:59 +0100 Subject: [PATCH 12/25] Fix Segment endings if followed by newline --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4f2caae5..ce49db7a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -363,7 +363,7 @@ prompt_newline() { "$1_prompt_segment" \ "$0" \ "$2" \ - "NONE" "NONE" "${newline}" + "" "" "${newline}" CURRENT_BG='NONE' POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws } From 2f05bbbb475fb032b9881a859ef4257c23274e8d Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 1 Feb 2019 11:09:42 +0100 Subject: [PATCH 13/25] Remove checking for NODEENV_DISABLE_PROMPT This variable is none of our buisness. --- powerlevel9k.zsh-theme | 5 ++--- test/segments/nodeenv.spec | 20 -------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 383a3b91..a4ac080a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1238,9 +1238,8 @@ prompt_nvm() { ################################################################ # Segment to display NodeEnv prompt_nodeenv() { - local nodeenv_path="$NODE_VIRTUAL_ENV" - if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - local info="$(node -v)[$(basename "$nodeenv_path")]" + if [[ -n "$NODE_VIRTUAL_ENV" ]]; then + local info="$(node -v)[${NODE_VIRTUAL_ENV:t}]" "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' fi } diff --git a/test/segments/nodeenv.spec b/test/segments/nodeenv.spec index 2e9d779e..1a9aaba8 100755 --- a/test/segments/nodeenv.spec +++ b/test/segments/nodeenv.spec @@ -44,26 +44,6 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() { unfunction node } -function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvDisablePromptIsSet() { - local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world) - local POWERLEVEL9K_CUSTOM_WORLD='echo world' - node() { - echo "v1.2.3" - } - NODE_VIRTUAL_ENV="node-env" - NODE_VIRTUAL_ENV_DISABLE_PROMPT=true - - # Load Powerlevel9k - source powerlevel9k.zsh-theme - - assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)" - - unset NODE_VIRTUAL_ENV_DISABLE_PROMPT - unset NODE_VIRTUAL_ENV - unfunction node -} - function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv) From c56cbb800aceb56f3cf56dfb6e32527fec7e4c2e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 1 Feb 2019 14:13:02 +0100 Subject: [PATCH 14/25] Add documentation --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33d787bb..c440ef2f 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ The segments that are currently available are: * `go_version` - Show the current GO version. * **Javascript / Node.js Segments:** * `node_version` - Show the version number of the installed Node.js. - * `nodeenv` - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. + * [`nodeenv`](#nodeenv) - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM * **PHP Segments:** * `php_version` - Show the current PHP version. @@ -557,6 +557,12 @@ prompt itself. This only works on the left side. On the right side it does nothing. +##### nodeenv + +Shows the currently used [nodeenv](https://github.com/ekalinin/nodeenv). To avoid +Nodeenvs activate command from interfering with Powerlevel9k, you should set +`NODE_VIRTUAL_ENV_DISABLE_PROMPT=1` in your `~/.zshrc`. + ##### rbenv This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. From f42214e44b8fa00b766ea2839b79160f0e804a34 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 1 Feb 2019 14:37:17 +0100 Subject: [PATCH 15/25] Add tests for newline segment --- test/segments/newline.spec | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 test/segments/newline.spec diff --git a/test/segments/newline.spec b/test/segments/newline.spec new file mode 100755 index 00000000..7cd00a89 --- /dev/null +++ b/test/segments/newline.spec @@ -0,0 +1,42 @@ +#!/usr/bin/env zsh +#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 + +# Required for shunit2 to run correctly +setopt shwordsplit +SHUNIT_PARENT=$0 + +function setUp() { + export TERM="xterm-256color" + + P9K_HOME=$(pwd) + ### Test specific +} + +function testNewlineDoesNotCreateExtraSegmentSeparator() { + local POWERLEVEL9K_CUSTOM_WORLD1="echo world1" + local POWERLEVEL9K_CUSTOM_WORLD2="echo world2" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline newline newline custom_world2) + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + local OS="OSX" # Fake OSX + + local newline=$'\n' + + assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%f${newline}%k%f${newline}%K{007} %F{000}world2 %k%F{007}%f " "$(build_left_prompt)" +} + +function testNewlineMakesPreviousSegmentEndWell() { + local POWERLEVEL9K_CUSTOM_WORLD1="echo world1" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline) + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + local OS="OSX" # Fake OSX + + local newline=$'\n' + + assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%F{none}%f " "$(build_left_prompt)" +} + +source shunit2/shunit2 \ No newline at end of file From 8f603093862d519caad072e102d22c515e8847b5 Mon Sep 17 00:00:00 2001 From: Wuestengecko <1579756+Wuestengecko@users.noreply.github.com> Date: Fri, 1 Feb 2019 17:43:52 +0100 Subject: [PATCH 16/25] Only abbreviate $HOME at the beginning of cwd Fixes #1150 --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 63724823..43d423a0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -797,7 +797,7 @@ prompt_dir() { # using $PWD instead of "$(print -P '%~')" to allow use of POWERLEVEL9K_DIR_PATH_ABSOLUTE local current_path=$PWD # WAS: local current_path="$(print -P '%~')" # check if the user wants to use absolute paths or "~" paths - [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path//$HOME/"~"} + [[ ${(L)POWERLEVEL9K_DIR_PATH_ABSOLUTE} != "true" ]] && current_path=${current_path/#$HOME/"~"} # declare all local variables local paths directory test_dir test_dir_length trunc_path threshhold # if we are not in "~" or "/", split the paths into an array and exclude "~" From 8bb86908d74097cda237115273acfdbaa5f39ea1 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 1 Feb 2019 23:48:39 +0100 Subject: [PATCH 17/25] Add tests --- test/segments/dir.spec | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 46e0cfb8..d75ca42f 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -768,4 +768,22 @@ function testDirSeparatorColorRootSubSubdirWorks() { rm -fr /tmp/powerlevel9k-test } +function testDirHomeTruncationWorksOnlyAtTheBeginning() { + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + + local FOLDER=/tmp/p9ktest + local SAVED_HOME="${HOME}" + HOME="/p9ktest" + + mkdir -p $FOLDER + # Setup folder marker + cd $FOLDER + assertEquals "%K{004} %F{000}/tmp/p9ktest %k%F{004}%f " "$(build_left_prompt)" + + cd - + rm -fr $FOLDER + HOME="${SAVED_HOME}" +} + source shunit2/shunit2 From 4b9ccc33bf9279b9bcb575f5088d0a139aeef71e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 3 Feb 2019 01:36:22 +0100 Subject: [PATCH 18/25] Fix issues with debug/fonts script in Konsole --- debug/font-issues.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 82f8e60b..6b505d36 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -222,13 +222,13 @@ END # Get Process ID of current konsole window / tab child="$(get_ppid "$$")" - IFS=$'\n' read -d "" -ra konsole_instances < <(qdbus | grep -F 'org.kde.konsole') + declare -a konsole_instances; konsole_instances=( "${(@f)"$(qdbus | grep -F 'org.kde.konsole')"/ /}" ) for i in "${konsole_instances[@]}"; do - IFS=$'\n' read -d "" -ra konsole_sessions < <(qdbus "$i" | grep -F '/Sessions/') + declare -a konsole_sessions; konsole_sessions=( "${(@f)"$(qdbus "$i" | grep -F '/Sessions/')"}" ) for session in "${konsole_sessions[@]}"; do - if ((child == "$(qdbus "$i" "$session" processId)")); then + if ((child == $(qdbus "$i" "$session" processId))); then profile="$(qdbus "$i" "$session" environment |\ awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')" break From 0081152c28edb96bd12d943803cd01cc5ac6e497 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 3 Feb 2019 08:35:46 +0100 Subject: [PATCH 19/25] Fix parsing font for Kitty --- debug/font-issues.zsh | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 6b505d36..6b663514 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -201,21 +201,13 @@ END ;; "kitty"*) - shopt -s nullglob - confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences}/kitty/kitty.con?) - shopt -u nullglob + kitty_config="$(kitty --debug-config)" + [[ "$kitty_config" != *font_family* ]] && return - [[ -f "${confs[0]}" ]] || return - - term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ { - $1 = ""; - gsub(/^[[:space:]]/, ""); - font = $0 - } - /^([[:space:]]*|[^#_])font_size[[:space:]]+/ { - size = $2 - } - END { print font " " size}' "${confs[0]}")" + term_font_size="${kitty_config/*font_size}" + term_font_size="${term_font_size/$'\n'*}" + term_font="${kitty_config/*font_family}" + term_font="${term_font/$'\n'*} $term_font_size" ;; "konsole"*) From 933e95d31c0fec2fbd3e4e3151337ac8293d7d49 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 3 Feb 2019 08:41:32 +0100 Subject: [PATCH 20/25] Use Konsole/Yakuake detection from upstream --- debug/font-issues.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 6b663514..c97ea34d 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -210,7 +210,7 @@ END term_font="${term_font/$'\n'*} $term_font_size" ;; - "konsole"*) + "konsole" | "yakuake") # Get Process ID of current konsole window / tab child="$(get_ppid "$$")" @@ -234,7 +234,7 @@ END profile_filename="${profile_filename/$'\n'*}" [[ "$profile_filename" ]] && \ - term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")" + term_font="$(awk -F '=|,' '/Font=/ {print $2,$3}' "$profile_filename")" ;; "lxterminal"*) From d83aacfb3ff01bf1839cf23e96ac9e6878663daa Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 9 Oct 2018 20:05:38 +0200 Subject: [PATCH 21/25] Fix font-debugging script for alacritty --- debug/font-issues.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index c97ea34d..135a6349 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -118,13 +118,13 @@ get_term_font() { case "$term" in "alacritty"*) - shopt -s nullglob + setopt nullglob confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) - shopt -u nullglob + unsetopt nullglob - [[ -f "${confs[0]}" ]] || return + [[ -f "${confs[1]}" ]] || return - term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")" + term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[1]}")" term_font="${term_font/*family:}" term_font="${term_font/$'\n'*}" term_font="${term_font/\#*}" From 0207182eb900a812ed42f47feadc7e24f43960ba Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 4 Dec 2018 08:28:07 +0100 Subject: [PATCH 22/25] Add missing function --- debug/font-issues.zsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 135a6349..9fd9be15 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -16,6 +16,12 @@ trim() { set +f } +trim_quotes() { + trim_output="${1//\'}" + trim_output="${trim_output//\"}" + printf "%s" "$trim_output" +} + get_ppid() { # Get parent process ID of PID. case "$os" in From cdf3fa51f21d3ec39cc9a54a9e6271dab11c8741 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 4 Dec 2018 08:28:27 +0100 Subject: [PATCH 23/25] Make variables optional --- debug/font-issues.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 9fd9be15..7435e9fe 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -119,6 +119,7 @@ get_term() { } get_term_font() { + local confs term_font mateterm_config role profile xrdb child profile_filename local term="${1}" # ((term_run != 1)) && get_term From 2fbdb8c982db7af4bec91ed6569351b18d5325b4 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 4 Dec 2018 08:32:04 +0100 Subject: [PATCH 24/25] Mute errors when detecting font --- debug/font-issues.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index 7435e9fe..dfd1f90e 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -163,26 +163,26 @@ END font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist" # Count Guids in "New Bookmarks"; they should be unique - profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" | \ + profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" 2>/dev/null | \ grep -w -c "Guid")" for ((i=0; i/dev/null)" if [[ "$profile_name" == "$current_profile_name" ]]; then # "Normal Font" term_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \ - "$font_file")" + "$font_file" 2>/dev/null)" # Font for non-ascii characters # Only check for a different non-ascii font, if the user checked # the "use a different font for non-ascii text" switch. diff_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \ - "$font_file")" + "$font_file" 2>/dev/null)" if [[ "$diff_font" == "true" ]]; then non_ascii="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \ - "$font_file")" + "$font_file" 2>/dev/null)" [[ "$term_font" != "$non_ascii" ]] && \ term_font="$term_font (normal) / $non_ascii (non-ascii)" From 0334f4c2659f413eb38ca52037c00d3823745d35 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 3 Feb 2019 08:58:46 +0100 Subject: [PATCH 25/25] Merge from upstream --- debug/font-issues.zsh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/debug/font-issues.zsh b/debug/font-issues.zsh index dfd1f90e..5712fc6d 100755 --- a/debug/font-issues.zsh +++ b/debug/font-issues.zsh @@ -192,13 +192,13 @@ END ;; "deepin-terminal"*) - term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a " " b}' \ + term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a,b}' \ "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")" ;; "GNUstep_Terminal") term_font="$(awk -F '>|<' '/>TerminalFontTerminalFontSizeTerminalFontSize