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

Re: Bug or Feature? Clear line before prompt.

On Fri, Oct 14, 2005 at 08:16:36AM +0200, Com MN PG P E B Consultant 3 wrote:
> Is there a way to tell zsh not to erase the line before writing the
> prompt?

This is taken from the FAQ:

  A better solution than disabling PROMPT_CR (for most terminals) is adding
  a simpler version of the PROMPT_SP (new in 4.3.0) functionality to an
  older zsh using a custom precmd function, like this one:

    # Skip defining precmd if the PROMPT_SP option is available.
    if ! eval '[[ -o promptsp ]] 2>/dev/null'; then
      function precmd {
        # Output an inverse char and a bunch spaces.  We include
        # a CR at the end so that any user-input that gets echoed
        # between this output and the prompt doesn't cause a wrap.
        print -nP "%B%S%#%s%b${(l:$((COLUMNS-1)):::):-}\r"

  That precmd function will only bump the screen down to a new line if there
  was output on the prompt line, otherwise the extra chars get removed by
  the PROMPT_CR action.  Although this typically looks fine it may result
  in the spaces preceding the prompt being included when you select a line
  of preserved text with the mouse.


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