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

Colours leaking from RPROMPT

Hi list,

I adapted a right-hand-side prompt for showing the run time of the
last command.  Code looks like this:

    function preexec() {
        timer=${timer:-$(date "+%s.%N")}

    function precmd() {
        if [ -n "$timer" ]; then
            new_timer=$(date "+%s.%N")
            timer_accurate=$(printf "scale=2; %s - %s\n" "$new_timer"
"$timer" | bc)
            timer_show=$(printf "%.2f" "$timer_accurate")
            RPROMPT="%F{cyan}${timer_show}s %{$reset_color%}"
            unset timer

I see some strange colour behaviour when using completions, though.
For instance, when I complete something with more than one possible
match, the completion menu is all coloured cyan.  And once I accept
one of the options from the completion menu, the unique substring that
was completed remains coloured cyan in the command string.  There are
also a couple of other odd behaviours that are not so easy to trigger.

The value of PS1 is '%n@%{%}%m%{%} %(!.#.$) '.

What would be the cause of this?  As far as I can see, the colour
should always be reset after the prompt string is printed, so it
should never show outside the prompt.


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