Check for $PSStyle variable

This commit is contained in:
Anthony Rose 2024-07-02 09:14:07 +01:00
parent b6daf28f13
commit 513c645436

View file

@ -115,44 +115,46 @@ Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert
# Colours for a light-coloured terminal. # Colours for a light-coloured terminal.
# https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-light-theme?view=powershell-7.2 # https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-light-theme?view=powershell-7.2
$ISETheme = @{ if ($null -ne $PSStyle) {
Command = $PSStyle.Foreground.FromRGB(0x0000FF) $ISETheme = @{
Comment = $PSStyle.Foreground.FromRGB(0x006400) Command = $PSStyle.Foreground.FromRGB(0x0000FF)
ContinuationPrompt = $PSStyle.Foreground.FromRGB(0x0000FF) Comment = $PSStyle.Foreground.FromRGB(0x006400)
Default = $PSStyle.Foreground.FromRGB(0x0000FF) ContinuationPrompt = $PSStyle.Foreground.FromRGB(0x0000FF)
Emphasis = $PSStyle.Foreground.FromRGB(0x287BF0) Default = $PSStyle.Foreground.FromRGB(0x0000FF)
Error = $PSStyle.Foreground.FromRGB(0xE50000) Emphasis = $PSStyle.Foreground.FromRGB(0x287BF0)
InlinePrediction = $PSStyle.Foreground.FromRGB(0x93A1A1) Error = $PSStyle.Foreground.FromRGB(0xE50000)
Keyword = $PSStyle.Foreground.FromRGB(0x00008b) InlinePrediction = $PSStyle.Foreground.FromRGB(0x93A1A1)
#ListPrediction = $PSStyle.Foreground.FromRGB(0x06DE00) Keyword = $PSStyle.Foreground.FromRGB(0x00008b)
Member = $PSStyle.Foreground.FromRGB(0x000000) #ListPrediction = $PSStyle.Foreground.FromRGB(0x06DE00)
Number = $PSStyle.Foreground.FromRGB(0x800080) Member = $PSStyle.Foreground.FromRGB(0x000000)
Operator = $PSStyle.Foreground.FromRGB(0x757575) Number = $PSStyle.Foreground.FromRGB(0x800080)
Parameter = $PSStyle.Foreground.FromRGB(0x000080) Operator = $PSStyle.Foreground.FromRGB(0x757575)
String = $PSStyle.Foreground.FromRGB(0x8b0000) Parameter = $PSStyle.Foreground.FromRGB(0x000080)
Type = $PSStyle.Foreground.FromRGB(0x008080) String = $PSStyle.Foreground.FromRGB(0x8b0000)
Variable = $PSStyle.Foreground.FromRGB(0xff4500) Type = $PSStyle.Foreground.FromRGB(0x008080)
#ListPredictionSelected = $PSStyle.Background.FromRGB(0x93A1A1) Variable = $PSStyle.Foreground.FromRGB(0xff4500)
Selection = $PSStyle.Background.FromRGB(0x00BFFF) #ListPredictionSelected = $PSStyle.Background.FromRGB(0x93A1A1)
Selection = $PSStyle.Background.FromRGB(0x00BFFF)
}
Set-PSReadLineOption -Colors $ISETheme
$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"
$PSStyle.FileInfo.Extension['.ps1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.ps1xml'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psd1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psm1'] = "`e[36m"
Remove-Variable ISETheme
} }
Set-PSReadLineOption -Colors $ISETheme
$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"
$PSStyle.FileInfo.Extension['.ps1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.ps1xml'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psd1'] = "`e[36m"
$PSStyle.FileInfo.Extension['.psm1'] = "`e[36m"
Remove-Variable ISETheme
# Keep this at the end. # Keep this at the end.
if (Test-Path "$PSScriptRoot/local.ps1") { if (Test-Path "$PSScriptRoot/local.ps1") {