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

Re: prompt color pbg ,pfg,pbg_bold,pfg_bold in colors function?



Matthias Kopfermann <matthi@xxxxxxxxxxxxxxxxx>:
> The fg, fg_bold associative array and bg and bg_bold in the
> colors function are quite useful.
> 
> For _prompts_ i have to surround every variable with %{ %} which
> does not , aehem, look too nice.
> what do you think? would it be fine to have that with
> wrapped around %{ %} , too so that not everybody has to put
> these around the keys or roll a prompt_colors_array on his
> own?
> 
> I think, i would love to be able to just use
> PS1=$pbg[red]%~ ...
> and it just works out of the box in every zsh.
> 
> Bad idea?

Not at all, IMHO.

I just think that the colors function would load quite a lot of
redundant information, if these are added as well. Maybe these
definitions could be added by a new function (e.g. prompt_colors).

Of course you could add code like:

[snip]
for i in ${(k)fg} ; do pfg[$i]="%{$fg[$i]%}" ; done
[snap]

to your .zshrc, but I guess a loadable function would be easier for
new users.

As an addition:
Today a user asked on IRC how to print out blinking text with the help
of the autoloadable colors function. I told him that, this would do:

[snip]
blink="\e[${color[blink]}m"
[snap]

Maybe it would be helpful to add this to the colors function:

[snip]
blink_color="$lc${color[blink]}$rc"
[snap]

Regards, Frank



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