I have created a powershell configuration file that modifies the prompt to add some color (depending on things like git branch, etc.)
This looks good, right up until I've executed a console program, like git, that also outputs colorized text. After this it seems Powershell decides to output escape codes verbatim.
Easier to understand with a screenshot:
- is the output before I run git, notice the colorized output of the text "colorized >"
- is the output after I run git, notice that the escape codes are output verbatim
Here's my Powershell configuration file:
function prompt {
"" + [char]0x001b + "[35m colorized >" + [char]0x001b + "[0m"
}
Is there a trick to re-enable the functionality of the ANSI codes or is this just some quirk of how either Powershell or git outputs text? Note that git is just an example, I've found several programs that messes this up, but not all of them do.
MSBuild, for example, works just fine.
prompt
function without needing escape codes (useWrite-Host
instead).