Use Microsoft-recommended light mode

This commit is contained in:
Anthony Rose 2025-02-13 09:58:56 +00:00
parent de6c36f321
commit 5217231f6e

View file

@ -118,41 +118,55 @@ foreach ($Property in $Host.PrivateData.PSObject.Properties.Name) {
}
}
[bool]$LightMode = $true
if ($LightMode) {
$Host.PrivateData.ErrorForegroundColor = [ConsoleColor]::DarkRed
$Host.PrivateData.ErrorBackgroundColor = [ConsoleColor]::White
$Host.PrivateData.WarningForegroundColor = [ConsoleColor]::DarkYellow
$Host.PrivateData.WarningBackgroundColor = [ConsoleColor]::White
$Host.PrivateData.DebugForegroundColor = [ConsoleColor]::DarkYellow
$Host.PrivateData.DebugBackgroundColor = [ConsoleColor]::White
$Host.PrivateData.VerboseForegroundColor = [ConsoleColor]::DarkYellow
$Host.PrivateData.VerboseBackgroundColor = [ConsoleColor]::White
$Host.PrivateData.ProgressForegroundColor = [ConsoleColor]::DarkYellow
$Host.PrivateData.ProgressBackgroundColor = [ConsoleColor]::White
$PSReadLineLightColors = @{
Default = "$([char]0x1b)[0m"
Command = "$([char]0x1b)[0m"
Comment = "$([char]0x1b)[32m"
ContinuationPrompt = "$([char]0x1b)[0m"
Emphasis = "$([char]0x1b)[36m"
Error = "$([char]0x1b)[91m"
InlinePrediction = "$([char]0x1b)[95m"
Keyword = "$([char]0x1b)[32m"
ListPrediction = "$([char]0x1b)[47;90m"
ListPredictionSelected = "$([char]0x1b)[100;97m"
ListPredictionTooltip = "$([char]0x1b)[45;33m"
Member = "$([char]0x1b)[0m"
Number = "$([char]0x1b)[31m"
Operator = "$([char]0x1b)[90m"
Parameter = "$([char]0x1b)[90m"
Selection = "$([char]0x1b)[7m"
String = "$([char]0x1b)[36m"
Type = "$([char]0x1b)[0m"
Variable = "$([char]0x1b)[32m"
function Set-AntLightMode {
# https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-light-theme
if ($PSVersionTable.PSVersion.Major -le 5) {
# $PSStyle doesn't exist in PowerShell 5.1, so import the external module.
Import-Module -Name PSStyle
}
Set-PSReadLineOption -Colors $PSReadLineLightColors
$ISETheme = @{
Command = $PSStyle.Foreground.FromRGB(0x0000FF)
Comment = $PSStyle.Foreground.FromRGB(0x006400)
ContinuationPrompt = $PSStyle.Foreground.FromRGB(0x0000FF)
Default = $PSStyle.Foreground.FromRGB(0x0000FF)
Emphasis = $PSStyle.Foreground.FromRGB(0x287BF0)
Error = $PSStyle.Foreground.FromRGB(0xE50000)
InlinePrediction = $PSStyle.Foreground.FromRGB(0x93A1A1)
Keyword = $PSStyle.Foreground.FromRGB(0x00008b)
ListPrediction = $PSStyle.Foreground.FromRGB(0x06DE00)
Member = $PSStyle.Foreground.FromRGB(0x000000)
Number = $PSStyle.Foreground.FromRGB(0x800080)
Operator = $PSStyle.Foreground.FromRGB(0x757575)
Parameter = $PSStyle.Foreground.FromRGB(0x000080)
String = $PSStyle.Foreground.FromRGB(0x8b0000)
Type = $PSStyle.Foreground.FromRGB(0x008080)
Variable = $PSStyle.Foreground.FromRGB(0xff4500)
ListPredictionSelected = $PSStyle.Background.FromRGB(0x93A1A1)
Selection = $PSStyle.Background.FromRGB(0x00BFFF)
}
$PSStyle.Formatting.FormatAccent = "`e[32m"
$PSStyle.Formatting.TableHeader = "`e[32m"
$PSStyle.Formatting.ErrorAccent = "`e[36m"
$PSStyle.Formatting.Error = "`e[31m"
$PSStyle.Formatting.Warning = "`e[33m"
$PSStyle.Formatting.Verbose = "`e[33m"
$PSStyle.Formatting.Debug = "`e[33m"
$PSStyle.Progress.Style = "`e[33m"
$PSStyle.FileInfo.Directory = $PSStyle.Background.FromRgb(0x2f6aff) +
$PSStyle.Foreground.BrightWhite
$PSStyle.FileInfo.SymbolicLink = "`e[36m"
$PSStyle.FileInfo.Executable = "`e[95m"
if ($PSVersionTable.PSVersion.Major -gt 5) {
$PSStyle.FileInfo.Extension['.ps1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.ps1xml'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psd1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psm1'] = "`e[36m"
}
Set-PSReadLineOption -Colors $ISETheme
}
Set-AntLightMode
# Keep this at the end.
if (Test-Path "$PSScriptRoot/local.ps1") {