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

Re: since 4.3.4, artifact-appearance at prompt



On Sun, Nov 04, 2007 at 09:48:03AM -0800, Bart Schaefer wrote:
>       function precmd {
>         # An efficient version using termcap multi-right:
>         print -nP '%B%S%#%s%b'      # Output % or #
>         echotc RI $((COLUMNS - 3))
>         echo -n '  '                # Output 2 spaces
>       }

You should replace the 2-space echo with a print that also outputs a CR:

       print -n '  \r'

This makes it less likely that the user's type-ahead after this output
will cause the screen to scroll (and is what the current code does).
Yes, the PROMPT_CR option is going to output a CR too, but it does so
after enough of a delay that I would sometimes see an inverted % on an
empty line if my type-ahead echoed between the PROMPT_SP output and the
PROMPT_CR output.

>     PS1=%P{%B%S%#%s%b}$PS1"
> 
> Any thoughts from the -workers on that?

It is better to output the %P portion as early as possible in the
post-command-run code, so outputting it as an actual part of the prompt
would probably not be desirable.  The PS1 string could get carved up
into early and normal prompt pieces, but it would probably just be
better to have an environment variable that specifies what to output.
e.g.:

PROMPTSP=%{%B%S%}%#%{%s%b%}

However, an alternative to having the user use %{ ... %} would be to
have the user just tell us how wide their string is:

PROMPTSP=1:%B%S%#%s%b

..wayne..



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