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.47k stars 947 forks source link

Many bugs in dir segment #1206

Closed romkatv closed 5 years ago

romkatv commented 5 years ago

I went to optimize prompt_dir in Powerlevel10k and noticed that the code is crawling with bugs. Just from the cursory look, here are some.

Tested on master with default settings plus whatever is specified in each test case.

1.

mkdir ~/'%E%K{red}'
cd ~/'%E%K{red}'

Expected content of dir segment: ~/%E%K{red}. Actual: color mayhem.

2.

mkdir ~/~
cd ~/~

Expected content of dir segment: ~/~. Actual: ~.

3.

POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true
mkdir ~/~
cd ~/~

Expected content of dir segment: /~. Actual: ~.

Note that with these settings we'll get /foo when we are in ~/foo. I'm assuming here this is the expected behavior of POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER although I cannot imagine why anyone would want this. What's clear is that it should be consistent between ~/foo and ~/~ but currently it isn't.

4.

POWERLEVEL9K_HOME_FOLDER_ABBREVIATION=HOME
sudo mkdir /~
cd /~

Expected content of dir segment: /~. Actual: /HOME.

dritter commented 5 years ago

I reproduced the issues on next and fixed them there. We are close to a new release, so I am closing this for now. Thanks @romkatv .