Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Bug with the new prompt redraw code



Consider the following:

  PS1_first_line=$'%{\e[1;32m%}[%d]%{\e[0m%}\n'
  PS1_second_line=$'%{\e[1;34m%}[%T]%{\e[1;32m%}%%%{\e[0m%} '

  precmd() {
    PS1="$PS1_first_line$PS1_second_line"
  }
  zle-line-init() {
    PS1="$PS1_second_line"
  }
  zle -N zle-line-init

This was intended to cause zsh to redraw only the second line of the two-
line prompt at any time other than completely starting over with a new
command.

Instead it has the effect of printing a garbage prompt.  This appears to 
occur because (1) zle-line-init runs before the prompt is displayed, which 
seems odd but wouldn't be a big deal except that (2) the prompt printing 
code has stashed a pointer to the value of $PS1, which ends up pointing at 
reclaimed memory when PS1 is re-assigned.



Messages sorted by: Reverse Date, Date, Thread, Author