I have added Git Bash to Windows Terminal as explained in Adding Git-Bash to the new Windows Terminal. My profile looks as follows:
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"name": "Git Bash",
"startingDirectory": "%USERPROFILE%",
}
I have a Picocli application that has colored output for the help message. When I invoke the help message in Git Bash in Windows Terminal it prints the ANSI color codes instead of coloring the text. To demonstrate this behavior I am using the example application of the Picocli docs:
When I run the same command on Git Bash's terminal the colors are rendered properly:
How can I get Git Bash in Windows Terminal to render ANSI colors in a Picocli application?
As shown on the below image, proper text coloring in Git Bash in Windows Terminal can happen (I demonstrate this with Robot Framework, which doesn't use Picocli), so my issue is specific to Picocli.
For showing ansi colors on Windows, I strongly recommend that applications use the Jansi library in combination with picocli.
Unless the specific software you’re using (e.g. java) enables ANSI processing by calling the SetConsoleMode API with the ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x0400) flag (java doesn’t), you won’t see colors or get ANSI processing for that application.
Jansi solves that issue.
For more details see: https://picocli.info/#_windows