Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #773 from conradhaupt/fix_dir_nav
Browse files Browse the repository at this point in the history
Fixed home abbreviation not being exclusive with circular navigation
  • Loading branch information
bhilburn committed Apr 14, 2018
2 parents 83e3267 + d43f128 commit 0d8bfb6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion powerlevel9k.zsh-theme
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions test/segments/dir.spec
Expand Up @@ -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'
Expand Down

0 comments on commit 0d8bfb6

Please sign in to comment.