Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
psvar + color
- X-seq: zsh-users 10977
- From: Michael Hernandez <sequethin@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: psvar + color
- Date: Mon, 13 Nov 2006 19:02:14 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=QGZ4ntjtaJ1GzxK366R0j2ugSXDjgyC56hLalmeXt3+EGHcolPEFX1PjKsn5GpCkblO9OWYDqYxulJh40RpWQr3xie9O6tHE9WF6Qc7u1JGLggHMX+pa2W21+3Q2FZUkN1NE+ckmd+blTuaPF+5sVYTQprifhCf3xFI9555GVOk=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
I am trying to dynamically set the color of my battery percentage in
my prompt. It's a long story, but I am using zsh 4.2.5 on OS X, along
with a slightly modified version of a zsh script called "battery"
which I found on line. I set the PROMPT_SUBST option, but that
doesn't seem to be helping (most likely I am just doing something
wrong).
I am using a version of the clint prompt and have been hacking away
at a copy of the file called prompt_clint_setup which is included
with the zsh distribution.
From what I see, there are precmd functions that set psvar[2] to the
current status, and psvar[2] is accessed as %2v
What I'd like to have is %2v (which could be *AC* (94.7%) for
example) change between green, yellow, or red depending on the
percentage. In this case it would be green, etc.
The problem is that no matter what I do, I can't get the color to
change by using %3v, for example, neither:
p_apm="${fg_no_bold[%3v]}%(2v.*%2v.) "
or
p_apm="%{$fg_no_bold[%3v]}%}%(2v.*%2v.) "
work properly.
In the spirit of trying every possible thing I could think of I even
tried p_apm="${fg_no_bold[$(print -P %3v)]}%(2v.*%2v.) "
If I simply use p_apm="${fg_no_bold[red]}%(2v.*%2v.) " - then the
percentage comes out in red, so I think my trouble is in the way
psvar is substituted through the %3v. I didn't think it would be a
problem because %2v changes frequently (if my battery is charging or
is unplugged at least) and I see the changes with each new prompt
when I press return. I was hoping that I could set the color in a
similar way. I have been checking psvar by echo $psvar[3] and also
print -P %3v after each prompt and it is being set to the correct
color. The more I look at it, the more the issue seems to be in the
color escape being substituted properly, not in the setting of $psvar[3]
What is it that I'm doing wrong? I'd post the whole file but I don't
want other mistakes of mine to distract attention from this one I am
currently trying to iron out. It's my hope to share the config in
it's entirety when it's complete, so that other os x users might
enjoy a conveniently colored battery state+ percentage in their
prompts if they wish :)
Any help is appreciated, thanks!
Mike H
Messages sorted by:
Reverse Date,
Date,
Thread,
Author