zsh-users
 help / color / mirror / code / Atom feed
* Colours leaking from RPROMPT
@ 2014-03-19 10:50 David Banks
  2014-03-19 22:34 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: David Banks @ 2014-03-19 10:50 UTC (permalink / raw)
  To: zsh-users

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
        fi
    }


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.

Thanks!
Dave


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-20 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 10:50 Colours leaking from RPROMPT David Banks
2014-03-19 22:34 ` Bart Schaefer
2014-03-20 14:53   ` David Banks

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).