1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-18 05:40:07 +00:00

Merge pull request #569 from docwhat/pr/home-folder-abbr-test

Added tests and replaced a sed call
This commit is contained in:
Ben Hilburn 2017-07-13 11:33:21 -04:00 committed by GitHub
commit c69d45cdcc
2 changed files with 26 additions and 1 deletions

View file

@ -794,7 +794,7 @@ prompt_dir() {
fi fi
if [[ "${POWERLEVEL9K_HOME_FOLDER_ABBREVIATION}" != "~" ]]; then 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 fi
typeset -AH dir_states typeset -AH dir_states

View file

@ -272,6 +272,31 @@ function testChangingDirPathSeparator() {
unset POWERLEVEL9K_DIR_PATH_SEPARATOR 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() { function testOmittingFirstCharacterWorks() {
POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
POWERLEVEL9K_FOLDER_ICON='folder-icon' POWERLEVEL9K_FOLDER_ICON='folder-icon'