Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 948 forks source link

POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" produces incorrect results under $HOME #1272

Open mr-salty opened 5 years ago

mr-salty commented 5 years ago

Describe Your Issue

What is happening? using the truncate_with_folder_marker strategy produced incorrect results under $HOME.

The first issue is, in a subdirectory of $HOME with no folder marker, an extra tilde is produced (~~/xxx).

In a subdirectory of a directory with a folder marker, the directory with the folder marker gets duplicated (~/xxx~/xxx/yyy)

~ > POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker"
~ > mkdir -p xxx/yyy/zzz
~ > touch xxx/.shorten_folder_marker
~ > cd xxx
~~/xxx > cd yyy
~/xxx~/xxx/yyy > cd zzz
~/xxx~/xxx/yyy/zzz >

Have you tried to debug or fix it?

I have a PR (#1271) to fix the first issue; I will also try to fix the second issue

Environment Information

This information will help us understand your configuration.

romkatv commented 5 years ago

While at it, consider fixing another bug in truncate_with_folder_marker. It doesn't respect POWERLEVEL9K_DIR_PATH_ABSOLUTE. That is, if you set POWERLEVEL9K_DIR_PATH_ABSOLUTE=true and POWERLEVEL9K_SHORTEN_STRATEGY=truncate_with_folder_marker, you'll get two kinds of unexpected behavior: