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

Inconsistent handling of named directories #1276

Open romkatv opened 5 years ago

romkatv commented 5 years ago

To reproduce:

docker run -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e TERM=$TERM -it --rm ubuntu bash -uexc '
  apt update && apt install -y zsh git
  git clone https://github.com/bhilburn/powerlevel9k.git ~/powerlevel9k
  echo "
    hash -d p9k=~/powerlevel9k
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
    POWERLEVEL9K_SHORTEN_STRATEGY=default
    POWERLEVEL9K_SHORTEN_DIR_LENGTH=9999
    source ~/powerlevel9k/powerlevel9k.zsh-theme" >~/.zshrc
  cd ~/powerlevel9k
  exec zsh'

The prompt will display ~p9k, the same as ${(%):-%~}. Now type unset POWERLEVEL9K_SHORTEN_DIR_LENGTH. The prompt changes to ~/powerlevel9k.

named-dir

This is unexpected. In both cases there was no shortening of the directory, so the prompt should be identical.

More generally, unless POWERLEVEL9K_DIR_PATH_ABSOLUTE is set to true, the first segment in dir segment should be the same as in ${(%):-%~}.