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

Re: Why does zsh clear to end-of-screen after prompt?



On Fri, Aug 25, 2023 at 5:59 PM John Hawkinson <jhawk@xxxxxxxxxxxx> wrote:
>
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote on Fri, 25 Aug 2023
> at 20:18:01 EDT in <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@xxxxxxxxxxxxxx>:
>
> > This happens because ZLE is a mult-line editor and also because
> > completion uses the space under the editor area to display lists etc.
> > If the screen were not cleared, text being edited could mingle with
> > the screen contents already present.
>
> Ugh. I suppose it would be too much to ask that it not do this in the (for me) 90+% case where neither completion nor multi-line editing have been used?

How about this, then?  I'd completely forgotten about "zle -T" ...

no_clr_eos () {
  emulate -L zsh
  if [[ $1 == cd ]]
  then
    REPLY=""
  elif [[ -n $2 ]]
  then
    REPLY=$(echotc "$@")
  else
    REPLY=$termcap[$1]
  fi
}
zmodload zsh/termcap
precmd() { zle -T tc no_clr_eos }
zle-line-init () { zle -Tr tc }
zle -N zle-line-init

No promises on how this affects performance.  Optionally add:

zle-line-finish() {
 CURSOR=$#BUFFER
 zle -R
 echotc cd
}
zle -N zle-line-finish

Conversion to add-zsh-hook / add-zle-hook-widget left as an exercise.




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