diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-07-13 18:33:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-13 18:33:21 +0300 |
commit | c69d45cdcce1f0d0542673be23b7c524eb83870d (patch) | |
tree | 9c6030b09e241835777b6a21367958df93a2ba56 | |
parent | ba41840ebc4a37eb81a9e7d398e21ff7327c4476 (diff) | |
parent | aca0f31eb00df91a2b40ac6baea8efb64bd84cab (diff) |
Merge pull request #569 from docwhat/pr/home-folder-abbr-test
Added tests and replaced a sed call
-rwxr-xr-x | powerlevel9k.zsh-theme | 2 | ||||
-rwxr-xr-x | test/segments/dir.spec | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b37f12c7..b08155ed 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -794,7 +794,7 @@ prompt_dir() { fi if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then - current_path="$( echo "${current_path}" | sed "s/^~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}/")" + current_path=${current_path/#\~/${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}} fi typeset -AH dir_states diff --git a/test/segments/dir.spec b/test/segments/dir.spec index b2991175..f4842f38 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -272,6 +272,31 @@ function testChangingDirPathSeparator() { unset POWERLEVEL9K_DIR_PATH_SEPARATOR } +function testHomeFolderAbbreviation() { + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION + local dir=$PWD + + cd ~/ + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" + + cd /tmp + # default + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + # substituted + POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + + cd "$dir" +} + function testOmittingFirstCharacterWorks() { POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true POWERLEVEL9K_FOLDER_ICON='folder-icon' |