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

print color escapes



All,

    $ print -r "\e[36msome cyanide salts are cyan\e[0m"
\e[36msome cyanide salts are cyan\e[0m

... does as expected, but how does one achieve the same 'literalness' if color escapes are in variables? I was forcing the 'colors' array to print bold colors and in the process the only way I could figure out to print the actual values of the 'fg[color]' colors was like this:

    $ print -r "before $($fg[cyan]) after"
    command not found: ^[[36m

... which is a bit clumsy, but it does at least show what's in there. I tried various things, but can't find a legit way of printing the values of the color escapes. How should it be done? Single quotes obviously won't work, double quotes seem needed to expand the variable, but I haven't found a way to stop it from being de-literalized. But there will be a way. Probably some magic nesting of braces. I'd expect 'print -r' to 'stay literal' with the expanded variable but no luck.



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