question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$PSStyle cause issues in the PowerShell Console

See original GitHub issue

Simple repro

Write-Verbose -verbose "verbose";Write-Output "out"

expected output

image

Actual results

image

VSCode reproduce

$PSVersionTable
$PSStyle.Formatting.Warning = $PSStyle.Background.Magenta + $PSStyle.Foreground.Yellow + $PSStyle.Bold + $PSStyle.Italic
Write-Warning "Colours!"

Expected behavior

image

and something like this:

image

Actual behavior

Notice the yellow:

image

image

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.2
PSEdition                      Core
GitCommitId                    7.2.0-preview.2
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rjmholtcommented, Dec 16, 2020

As for the style not taking effect, yeah every custom host will need to implement this themselves.

I think we need a bit more platform-oriented thinking here

1reaction
SeeminglySciencecommented, Feb 4, 2021

Hmm I can’t repro the color leaking. (Edit: Didn’t have the experimental feature enabled) As for the style not taking effect, yeah every custom host will need to implement this themselves.

It would be nice if ConsoleHost was redesigned somewhat to be inheritable. That doesn’t really help PSES and such right now unless it’s polyfilled but it would save a lot of headache in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using PowerShell with $PSStyle
Be aware that any changes to $PSStyle are not persistent unless you add them to your PowerShell profile script.
Read more >
about Preference Variables - PowerShell
PowerShell includes a set of variables that enable you to customize its behavior. These preference variables work like the options in ...
Read more >
Is it possible to stop `powershell` wrapping output in ANSI ...
This causes PowerShell to set $PSStyle.OutputRendering to PlainText on startup, which instructs PowerShell not to use VT / ANSI escape ...
Read more >
Setting the Style in PowerShell 7.2 - TechGenix
PowerShell's newfound support for ANSI escape sequences allow you to ... You can use the $PSStyle variable to set the background color.
Read more >
Change color of PowerShell 7 Get-ChildItem result
So to change file and directory colours, set the appropriate property in the $PSStyle.FileInfo object to the ANSI escape sequence representing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found