Skip to content

Commit

Permalink
Merge remote-tracking branch 'ytang/fix-icons-cut-off' into staging_065
Browse files Browse the repository at this point in the history
Conflicts were:
- test/segments/command_execution_time.spec and
test/segments/go_version.spec: All conflicts come from renaming color
names on next (Powerlevel9k#703) and adding a whitespace to the Visual Identifier
(Powerlevel9k#854) on master.
  • Loading branch information
dritter committed Jun 6, 2018
2 parents 5eedb25 + 9c4203b commit e907f9c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,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.|
Expand Down
12 changes: 8 additions & 4 deletions powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ 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.
# 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
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

Expand Down Expand Up @@ -241,12 +243,14 @@ 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.
# 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
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

Expand Down
6 changes: 3 additions & 3 deletions test/powerlevel9k.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions test/segments/command_execution_time.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ function testCommandExecutionTimeThresholdCouldBeChanged() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
_P9K_COMMAND_DURATION=2.03

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand All @@ -40,7 +44,11 @@ function testCommandExecutionTimeThresholdCouldBeSetToZero() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
_P9K_COMMAND_DURATION=0.03

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand All @@ -53,7 +61,11 @@ function testCommandExecutionTimePrecisionCouldBeChanged() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
_P9K_COMMAND_DURATION=0.0001

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand All @@ -66,7 +78,11 @@ function testCommandExecutionTimePrecisionCouldBeSetToZero() {
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
_P9K_COMMAND_DURATION=23.5001

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand All @@ -77,7 +93,11 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand()
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=180

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand All @@ -87,7 +107,11 @@ function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
_P9K_COMMAND_DURATION=7200

<<<<<<< HEAD
assertEquals "%K{red} %F{yellow1%}Dur%f %F{yellow1}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)"
>>>>>>> ytang/fix-icons-cut-off

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unset _P9K_COMMAND_DURATION
Expand Down
10 changes: 5 additions & 5 deletions test/segments/dir.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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%F{black}~ %k%F{blue}%f " "$(build_left_prompt)"

cd -
unset POWERLEVEL9K_HOME_ICON
Expand All @@ -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%F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"

cd -
rm -fr $FOLDER
Expand All @@ -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%F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)"

cd -
rm -fr $FOLDER
Expand Down Expand Up @@ -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%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)"

cd -
unset POWERLEVEL9K_FOLDER_ICON
Expand All @@ -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%F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"

cd -
rm -fr /tmp/powerlevel9k-test
Expand Down
2 changes: 1 addition & 1 deletion test/segments/go_version.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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%F{grey93}go1.5.3 %k%F{green}%f " "$(build_left_prompt)"

unset POWERLEVEL9K_GO_ICON
unset PWD
Expand Down
4 changes: 2 additions & 2 deletions test/segments/kubecontext.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl
Expand All @@ -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%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"

unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl
Expand Down

0 comments on commit e907f9c

Please sign in to comment.