From a761e3c28a78cfbf7d7ca9cde5bdcd1126c2996c Mon Sep 17 00:00:00 2001 From: Conrad Haupt Date: Mon, 12 Mar 2018 14:28:17 +0200 Subject: [PATCH 1/2] Fixed home abbreviation not being exclusive with circular navigation --- powerlevel9k.zsh-theme | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..12d05db3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -809,7 +809,9 @@ prompt_dir() { current_path="${cur_short_path: : -1}" ;; *) - current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + if [[ $current_path != "~" ]]; then + current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")" + fi ;; esac fi From 83ad5b598e1524fa76055f8ed086eb155c39c580 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 20 Mar 2018 22:39:20 +0100 Subject: [PATCH 2/2] Add test for wrong truncation if switching back to home folder This happens if a user switches from a subdirectory of $HOME back to the home folder and truncation strategy is "truncate folders from left". Then the folder is displayed as .../~ PR: #773 --- test/segments/dir.spec | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/segments/dir.spec b/test/segments/dir.spec index ef27e160..97bc857c 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -36,6 +36,27 @@ function testTruncateFoldersWorks() { unset POWERLEVEL9K_SHORTEN_STRATEGY } +function testTruncateFolderWithHomeDirWorks() { + POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + CURRENT_DIR=$(pwd) + + cd ~ + FOLDER="powerlevel9k-test-${RANDOM}" + mkdir -p $FOLDER + cd $FOLDER + # Switch back to home folder as this causes the problem. + cd .. + + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + rmdir $FOLDER + cd ${CURRENT_DIR} + + unset CURRENT_DIR + unset FOLDER + unset POWERLEVEL9K_SHORTEN_DIR_LENGTH +} + function testTruncateMiddleWorks() { POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'