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 949 forks source link

Right prompt overlaps left prompt #1306

Closed romkatv closed 4 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 '
  cd
  apt update && apt install -y zsh git
  git clone https://github.com/bhilburn/powerlevel9k.git
  echo "
    POWERLEVEL9K_PROMPT_ON_NEWLINE=true
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_left)
    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_right)
    typeset POWERLEVEL9K_CUSTOM_{LEFT,RIGHT}=\"echo \${(pl.\$((COLUMNS/2))..-.)}\"
    POWERLEVEL9K_CUSTOM_LEFT_BACKGROUND=red
    POWERLEVEL9K_CUSTOM_RIGHT_BACKGROUND=blue
    source ~/powerlevel9k/powerlevel9k.zsh-theme" >~/.zshrc
  exec zsh'

Actual:

actual

Expected:

expected

Normally, ZSH doesn't display right prompt if it would overlap left prompt. If you type the following command, you won't see right prompt.

PROMPT="${(pl.$((COLUMNS/2))..-.)}> " RPROMPT="<${(pl.$((COLUMNS/2))..-.)}" zsh -df

Now, if you make your terminal wider, right prompt will appear.

If you remove POWERLEVEL9K_PROMPT_ON_NEWLINE=true from the p9k config above, right prompt won't be displayed, as expected.

docker run -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e TERM=$TERM -it --rm ubuntu bash -uexc '
  cd
  apt update && apt install -y zsh git
  git clone https://github.com/bhilburn/powerlevel9k.git
  echo "
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_left)
    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_right)
    typeset POWERLEVEL9K_CUSTOM_{LEFT,RIGHT}=\"echo \${(pl.\$((COLUMNS/2))..-.)}\"
    POWERLEVEL9K_CUSTOM_LEFT_BACKGROUND=red
    POWERLEVEL9K_CUSTOM_RIGHT_BACKGROUND=blue
    source ~/powerlevel9k/powerlevel9k.zsh-theme" >~/.zshrc
  exec zsh'

one-line-prompt

laggardkernel commented 5 years ago

There's no builtin support for putting right prompt on the same line with left prompt.

https://github.com/bhilburn/powerlevel9k/blob/3057e8fc07374e9c580790a023cb85998ca91fc8/powerlevel9k.zsh-theme#L1823-L1827

You can't expect everything works perfectly in an "ugly workaround", right?

romkatv commented 5 years ago

There's no builtin support for putting right prompt on the same line with left prompt.

True. There is also no builtin support for Git status, command execution time, nvm or pretty much anything Powerlevel9k provides. If everything was builtin in ZSH, there would be no reason for Powerlevel9k to exist.

You can't expect everything works perfectly in an "ugly workaround", right?

Of course I expect the current implementation to do exactly what it does. Sometimes, what the current implementation does is not what users expect or desire. We call them bugs.

I cannot speak for all users but to me the current behavior is neither expected nor desired. I gather from your comment that you share this opinion. If your point is that fixing the bug is hard, I wholeheartedly agree. It's possible though. I'm not at liberty to point to the solution on this forum. You likely can guess where it can be found.

dritter commented 4 years ago

Fixed on next with #1335

Thanks @romkatv for the Bug reports.