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

Escape characters in $psvar[]



Hey list,

The following came up on IRC.

A user uses the `clint' prompt, which uses `psvar' to include results
from `vcs_info'. He wanted to include colour codes in the vcs_info
formats for proper eye candy. Which resulted in literal "^[[35m" strings
in the actual prompt instead of colours.

It seems using $psvar[] replaces escape characters (ascii 0x1b) with two
characters: `^' and `[':

[snip]
% autoload -Uz colors
% colors
% psvar[9]=$fg[red]foo
% print ${psvar[9]} | hd -c
00000000  1b 5b 33 31 6d 66 6f 6f  0a                       |.[31mfoo.|
0000000 033   [   3   1   m   f   o   o  \n                            
0000009
% print -P '%9v' | hd -c
00000000  5e 5b 5b 33 31 6d 66 6f  6f 0a                    |^[[31mfoo.|
0000000   ^   [   [   3   1   m   f   o   o  \n                        
000000a
[snap]

Is that indented behaviour or a bug? A quick skim through the docs
didn't turn up an answer.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



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