Choosing a good set of colours for PowerShell can make it easier to read and work with, but these are set in several different places.
First stop is the Window menu: Properties/Defaults (Alt-Spacebar).
This allows you to set the Screen Text and background colour, and in addition each colour can be modified.
The traditional Dark Blue Screen Background for PowerShell is Red: 1, Green: 36, Blue: 86. In hex, 012 456.
The other examples above are Black and RGB: 0, 0, 128 (#000080).
For many years, PowerShell defaulted to a blue background and the CMD Command Prompt shell to a black background, this is very convenient for telling them apart but is not foolproof: you can run a CMD shell session from PowerShell and you can run a PowerShell session from CMD. These will inherit the background colour of the parent session.
The next setting we can tweak is $host.UI for example:
$myhost = $host.UI.RawUI
$myhost.ForegroundColor = "White"
$myhost.BackgroundColor = "DarkBlue"Now you might think, “why bother coding this when I could just set the Window menu properties and call it a day?” The key difference is that $host.UI commands can be stored in your PowerShell profile and that can be shared between multiple machines.
Also under the $host.privatedata automatic variable are some additional color settings:
ErrorForegroundColor : Red
ErrorBackgroundColor : Black
WarningForegroundColor : Yellow
WarningBackgroundColor : Black
DebugForegroundColor : Yellow
DebugBackgroundColor : Black
VerboseForegroundColor : Yellow
VerboseBackgroundColor : Black
ProgressForegroundColor : Yellow
ProgressBackgroundColor : DarkCyanThese can be modified and, as with $host.UI, applied at the command line or via your PowerShell profile:
$mycolours = $host.PrivateData
$mycolours.ErrorBackgroundColor = "Blue"
$mycolours.ErrorForegroundColor = "Black"The full list of available ConsoleColor names can be found in the table below.
Yet more colour configurations can be done with Get-/Set-PSReadLineOption
This gives you control of the syntax highlighting e.g.
Set-PSReadLineOption -Colors @{
Comment = 'White'
Operator = 'White'
Parameter = 'White'
}
Another way to get a good looking terminal, is to install and use Windows Terminal which allows you to choose from a number of themes, for a classic blue theme choose: Campbell PowerShell.
| ConsoleColor Name | ANSI Color Name | Windows Terminal Theme Key |
|---|---|---|
| Black | Black | black |
| DarkGray | BrightBlack | brightBlack |
| Gray | White | white |
| White | BrightWhite | brightWhite |
| DarkRed | Red | red |
| Red | BrightRed | brightRed |
| DarkMagenta | Magenta | purple |
| Magenta | BrightMagenta | brightPurple |
| DarkBlue | Blue | blue |
| Blue | BrightBlue | brightBlue |
| DarkCyan | Cyan | cyan |
| Cyan | BrightCyan | brightCyan |
| DarkGreen | Green | green |
| Green | BrightGreen | brightGreen |
| DarkYellow | Yellow | yellow |
| Yellow | BrightYellow | brightYellow |
| n/a | n/a | background |
| n/a | n/a | foreground |
| n/a | n/a | cursorColor |
| n/a | n/a | selectionBackground |
“I wanted to be soft like Rothko and ruthless like Ad Reinhardt” ~ Jenny Holzer
How-to: ANSI Colors Use ANSI colours in the Windows Terminal.
EchoANSI - PS script to display colours.
managedux.com - Set the color for CMD and PowerShell based on admin / elevation status.
Brice’s Color Scheme - for Windows terminal.
Terminalsplash.com - A multitude of Windows terminal themes.
COLOR - Change colours of the CMD window.
WT.exe - Windows Terminal.