Custom powershell backgroundcolor reverts when running commands?

mmseng

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.

Drew

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]

編集
0

コメントを追加

0

関連記事

分類Dev

Running commands from Powershell

分類Dev

React State Reverts to Previous When Navigating Away

分類Dev

VSC throwing an error when running powershell script

分類Dev

Variable notation when running python commands with arguments in a bash script

分類Dev

Logs directory permission denied error when running Artisan commands

分類Dev

Having issue getting custom console commands to work in Yii2 whilst running multiple applications

分類Dev

running sequential commands on nohup

分類Dev

getting property value in powershell when running convertto-html

分類Dev

Why PowerShell opens a new window when running exe

分類Dev

pre-loading custom functions when running sheets daily script

分類Dev

Python crashing when I'm running the program with a custom loss function

分類Dev

powershell module startup commands

分類Dev

Run powershell commands atomically

分類Dev

How to perform a custom method when a PowerShell module is imported?

分類Dev

How to execute TMUX commands on a remote server when I have TMUX running locally too?

分類Dev

When can I use newlines (line breaks) in my Powershell commands to improve readability

分類Dev

Commands aren't exported when importing a PowerShell Binary Module on a Linux container

分類Dev

Running commands from Controller async

分類Dev

powershell will not keep commands in function call

分類Dev

Is it possible to add custom commands to tmux?

分類Dev

How can I customize powershell when running inside of the VSCode integrated terminal?

分類Dev

How to stop a windows 10 machine from sleeping/hibernating down when running a powershell process?

分類Dev

Powershell script won't launch in task scheduler when running as my admin user

分類Dev

Send data and user commands to running Puppeteer script

分類Dev

running ssh and executing commands on remote machines

分類Dev

"Invalid array passed in..." when i tried to pass a string as parameter to a powershell function in Azure Custom Script Extension

分類Dev

Running PowerShell from .NET Core

分類Dev

Running PowerShell from .NET Core

分類Dev

PowerShell - Nesting Try/Catch/Finally Commands

Related 関連記事

  1. 1

    Running commands from Powershell

  2. 2

    React State Reverts to Previous When Navigating Away

  3. 3

    VSC throwing an error when running powershell script

  4. 4

    Variable notation when running python commands with arguments in a bash script

  5. 5

    Logs directory permission denied error when running Artisan commands

  6. 6

    Having issue getting custom console commands to work in Yii2 whilst running multiple applications

  7. 7

    running sequential commands on nohup

  8. 8

    getting property value in powershell when running convertto-html

  9. 9

    Why PowerShell opens a new window when running exe

  10. 10

    pre-loading custom functions when running sheets daily script

  11. 11

    Python crashing when I'm running the program with a custom loss function

  12. 12

    powershell module startup commands

  13. 13

    Run powershell commands atomically

  14. 14

    How to perform a custom method when a PowerShell module is imported?

  15. 15

    How to execute TMUX commands on a remote server when I have TMUX running locally too?

  16. 16

    When can I use newlines (line breaks) in my Powershell commands to improve readability

  17. 17

    Commands aren't exported when importing a PowerShell Binary Module on a Linux container

  18. 18

    Running commands from Controller async

  19. 19

    powershell will not keep commands in function call

  20. 20

    Is it possible to add custom commands to tmux?

  21. 21

    How can I customize powershell when running inside of the VSCode integrated terminal?

  22. 22

    How to stop a windows 10 machine from sleeping/hibernating down when running a powershell process?

  23. 23

    Powershell script won't launch in task scheduler when running as my admin user

  24. 24

    Send data and user commands to running Puppeteer script

  25. 25

    running ssh and executing commands on remote machines

  26. 26

    "Invalid array passed in..." when i tried to pass a string as parameter to a powershell function in Azure Custom Script Extension

  27. 27

    Running PowerShell from .NET Core

  28. 28

    Running PowerShell from .NET Core

  29. 29

    PowerShell - Nesting Try/Catch/Finally Commands

ホットタグ

アーカイブ