Re:ANSI escape codes (2019)
by chasil on Wednesday February 03, 2021 @11:06AM
(#26014943)
This is my korn-shell fragment that I use to set up color codes. Everything but the final print is posix-compliant (change it to a printf to run under bash).
[ Parent
| on HN ]
This is one of the many cool things that zsh comes with out of the box. It ships an autoload-able colors¹ script that does largely the same thing as your fragment, but you know it available wherever zsh is.
In much the same way it comes with both a termcap² and terminfo³ module, allowing you to easily avoid hardcoding system specific escapes in to your config.
¹ https://github.com/zsh-users/zsh/blob/master/Functions/Misc/...
² http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-...
³ http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-...