Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Colours leaking from RPROMPT
- X-seq: zsh-users 18632
- From: David Banks <amoebae@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Colours leaking from RPROMPT
- Date: Wed, 19 Mar 2014 10:50:50 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=jQeL15qIa8H6WJKr6+F6mxDSd3n0yMxQN++z042GpHY=; b=Tiyp6/Yr0l5gPCbR9OrWqfvE2cN2Tu2beQTgS/luupQLQbZ+H/SZxdh4W9LtKebf0i eHH0S7i7lXD/XK+MXjAQFBe69DjIXx1+6zIX8uezoTpxPU50mFIPEyxXNSP2jn3M4HjX rCo2e0gAkP4aaG1OIGKTWW4HdDSwhTf17tp+t3lbeaaxOX6YLlzVzwlOtAXyY+nfATAV fqCozohzO3wCZzcPLaGLT3kXG2YC5OqL04gJlBzTRyiAC29Qd9QVGFxqwlCiZHgyuWKD VTedRYihc1+rimFyJjDkvw0DIIx43kKlkLHs5P0DN+HNi002bUzi/dKZZa/oFMSXeLra tkqQ==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author