I'm using a powershell profile to change the background color of the powershell console (to black) when its running as my superuser account, or based on other criteria. I do this simply by setting the following variables in my profile ps1.
$host.ui.rawui.backgroundcolor = "black"
$host.ui.rawui.foregroundcolor = "white"
Console windows using this profile open with a black background, and the initial prompt is white text with a black background. Hitting Enter
without typing anything doesn't change this.
However as soon as I enter any text whatsoever, the background color of the typed text, the prompts, and any output (except for errors) reverts to being the default white on navy blue. The overall console background remains black.
Reloading the profile with . .\path\profile.ps1
or manually resetting the $host
variables (as above) reverts the prompt to white on black, but the same behavior happens again. The most bizarre thing is that even typing text then backspacing it and entering nothing still causes the prompt to revert to navy.
Is there any way to actually have a pure black background, or is this just a limitation of the powershell console (v5.1 btw)?
I've seen some references to other color-related variables, but I don't see how they are helpful in this regard:
$host.PrivateData.ErrorForegroundColor
$host.PrivateData.ErrorBackgroundColor
$host.PrivateData.WarningForegroundColor
$host.PrivateData.WarningBackgroundColor
$host.PrivateData.DebugForegroundColor
$host.PrivateData.DebugBackgroundColor
$host.PrivateData.VerboseForegroundColor
$host.PrivateData.VerboseBackgroundColor
$host.PrivateData.ProgressForegroundColor
$host.PrivateData.ProgressBackgroundColor
P.S. I'd post an image, but my prompt and stuff has personal info in it. I sure can't wait for the fancy new Terminal MS announced last month. I can only hope it's far less cumbersome than this.
You will need to change your PSReadLineOption
options accordingly as well as the RawUI
and PrivateData
.
See Get-PSReadlineOption
to fine the current colours and what adjust them with Set-PSReadlineOption -TokenKind $token -BackgroundColor Black
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加