Search code examples
jsonpowershellwindows-terminalpowershell-5.1powershell-7.3

Powershell v7 Text Background highlighting


So I set up my new laptop with both powershell 5.1 to powershell 7 and I just have this weird problem with powershell 7 where it highlights the background of the text which I just don't like.

I do not face this problem with powershell 5.1. I tried to change that background in the color scheme in "settings.json" to an alpha channel for transparency but powershell doesn't accept rgba values so it errors out.

Here's an example image of the problem I'm facing

PowerShell 7: Powershell V7

PowerShell 5.1: Powershell 5.1

Please help me resolve this issue :)


Solution

  • PowerShell 7.2 introduced the automatic variable $PSStyle for a new feature called PSAnsiRendering. You can use ANSI rendering to control text decorations, such as colour and font styling, in PowerShell. See Get-Help about_ANSI_Terminals for more information.

    This includes File Info formatting when using Get-Childitem, you can alter the formatting with $PSStyle.FileInfo.Directory for example

    $PSStyle.FileInfo.Directory = "`e[4;1m"
    

    Or disable with

    $PSStyle.OutputRendering = "Plaintext"
    

    If you'd like to keep this consistent for each session then you'll need to add it to your PowerShell profile script.