Prerequisites
Steps to reproduce
Note:
-
I don't know whether the intent is for Write-Host -Fore/BackgroundColor to respect $PSStyle.OutputRendering = 'PlainText' or not - arguably, it should.
- Update: Arguably, it should respect all modes, so that
'Host' can be used to use color only when printing to the terminal, and 'ANSI' to request unconditional coloring.
-
De facto, it currently isn't respected - ever - on Windows, and only situationally on Unix-like platforms
& {
# A preexisting NO_COLOR environment variable sets `$PSStyle.OutputRendering = 'PlainText'` in the session
# created by the CLI call.
$env:NO_COLOR = 1
pwsh -noprofile -c 'Write-Host -ForegroundColor Blue hi'
$env:NO_COLOR = $null
}
& {
# Set `$PSStyle.OutputRendering = 'PlainText'` in-session
$prev = $PSStyle.OutputRendering
$PSStyle.OutputRendering = 'PlainText'
Write-Host -ForegroundColor Blue hi
$PSStyle.OutputRendering = $prev
}
Expected behavior
Either both 'hi' instances should be blue (as currently on Windows), or, preferably, both should use the default foreground color.
Actual behavior
- On Windows, both 'hi' instances are blue.
- On Unix-like platforms, the first 'hi' uses the default color, and the second one is blue.
Error details
No response
Environment data
Visuals
No response