In ZSH, when the terminal size is reconfigured, multi-line prompt texts are not properly shown

PROBLEM DESCRIPTION


When using ZSH in shell and the terminal size is reconfigured, the first line of multi-line prompt texts are shown twice.


prompt 1st line

prompt 2nd line >


After terminal size is reconfigured...

prompt 1st line

prompt 1st line

prompt 2nd line >


Test Instructions:

  1. Execute zsh, then enter in following command to create a multi-line prompt text

    export PROMPT ="[%n@%m][%D{%Y.%m.%d %H.%M}][%~]] >"
  2. Adjust the window size of the terminal
  3. Check if first line is shown twice



REASON


This is a bug within zsh that has existed since 3/19/2009. It is not a bug unique to a specific terminal emulator, but instead affects all terminal emulators.



RESOLUTION


Currently, zsh developers are looking into this issue. However, an official solution currently does not exist. Use the command 'print -rP "...."' in zsh for multi-line prompt texts.

ex) export PROMPT=`print -rP "[%n@%m][%D] >"`