Why Aren’t ANSI Escape Codes Working in PowerShell?

0
0
Asked By CuriousCat987 On

Hey everyone, I'm having some trouble with ANSI escape codes in PowerShell. They don't seem to render correctly when I'm using **Select-String** in the main PowerShell console, but they work just fine in the VS Code terminal. I noticed that if I assign the output of a command to a variable, like in `$a = yt-dlp --help; $a | sls config`, it displays correctly. I'm not sure if this is a bug or if I've done something wrong. Would appreciate any insights!

1 Answer

Answered By TechWhiz24 On

What OS are you on? It looks like your PowerShell window might be running in conhost.exe, which is the default on older systems. This version didn't support ANSI escape codes until Windows 10. If you’re on an older OS, that could be the issue. You might want to try using Windows Terminal, which offers better support, but you'll need at least Win10 version 1904.

CuriousCat987 -

I'm on Windows 11 home 22H2. But as I mentioned, when I assign the output to a variable, it works as expected. Just sharing the example again.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.