Up until recently my experiences using the Tanzu CLI have all been from Linux boxes. When Tanzu Community Edition was released I decided to prepared a Windows Bootstrap client and install and configure TKG this time from within Windows. I noticed early on that the Tanzu CLI was outputting some strangely formatted text.
I’d never seen this before in Linux using the Tanzu CLI. Characters like ←[1m and ←[0m were printed next to words making it very difficult to read the screen. A little bit of research showed that these were ANSI color escape sequences.
Whether I used the native PowerShell 5 in Windows, PowerShell 7, or the Command Prompt they all produced the same strangely outputted text. Using ANSI escape sequences like this has always been a little sketchy in PowerShell. I tried the new Windows Terminal which does a much better job of handling this stuff and sure enough the issue disappeared.
A bit more digging around and I found that in Windows 10 (Build 16257) and above you can enable ANSI escape sequences via a registry key which can resolve this specific issue in PowerShell and the Command Prompt. The below fix will allow the use of ANSI text formatting and colors.
Open up Regedit and navigate to HKEY_CURRENT_USER\Console. Create a new DWORD value and set the Name to VirtualTerminalLevel and the Data value to 1.
A reboot is not necessary. Just close any PowerShell or Command Prompt windows you have open. Start up another PowerShell session and execute the Tanzu CLI by typing in tanzu. This time the text should be correctly formatted with Bold and Underline sections.