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

[Bugfix] Fix extra tilde when using truncate_with_folder_marker under $HOME #1271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ prompt_dir() {
trunc_path="/"
elif [[ "$marked_folder" == "$HOME" ]]; then
# If we reached home folder, stop upsearch.
trunc_path="~"
trunc_path=""
elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then
trunc_path="${trunc_path%/}/${marked_folder##*/}"
else
Expand Down
22 changes: 22 additions & 0 deletions test/segments/dir.spec
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,28 @@ function testTruncateWithFolderMarkerWorks() {
rm -fr $BASEFOLDER
}

function testHomeWithFolderMarkerWorks() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
local dir=$PWD

mkdir -p ~/powerlevel9k-test

# Load Powerlevel9k
source ${P9K_HOME}/powerlevel9k.zsh-theme

cd ~
assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)"

cd ~/powerlevel9k-test
assertEquals "%K{004} %F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"

cd $dir
rm -fr ~/powerlevel9k-test
}

function testTruncateWithFolderMarkerWithChangedFolderMarker() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
Expand Down