Skip to content

Commit 4b34925

Browse files
authored
Update ANSI color articles based on UUF notes (#12571)
* Update ANSI color articles based on UUF notes * Fix suggestion from Copilot and normalize colors
1 parent dd9bd86 commit 4b34925

File tree

4 files changed

+86
-38
lines changed

4 files changed

+86
-38
lines changed

reference/7.4/Microsoft.PowerShell.Core/About/about_ANSI_Terminals.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the features of PowerShell that use ANSI escape sequences and the terminal hosts that support them.
33
Locale: en-US
4-
ms.date: 08/27/2024
4+
ms.date: 12/09/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_ANSI_Terminals
@@ -183,8 +183,23 @@ The following members control how or when ANSI formatting is used:
183183
- **SymbolicLink** - Built-in member to specify color for symbolic links
184184
- **Executable** - Built-in member to specify color for executables.
185185
- **Extension** - Use this member to define colors for different file
186-
extensions. The **Extension** member pre-includes extensions for archive
187-
and PowerShell files.
186+
extensions. The **Extension** member predefines colors for archive and
187+
PowerShell file extensions.
188+
189+
The following example shows how to change the colors for various `FileInfo`
190+
settings and specific file extensions. The colors are chosen to work well
191+
on a light terminal background.
192+
193+
```powershell
194+
$PSStyle.FileInfo.Directory = $PSStyle.Background.FromRgb(0x2f6aff) +
195+
$PSStyle.Foreground.BrightWhite
196+
$PSStyle.FileInfo.SymbolicLink = $PSStyle.Foreground.Cyan
197+
$PSStyle.FileInfo.Executable = $PSStyle.Foreground.BrightMagenta
198+
$PSStyle.FileInfo.Extension['.ps1'] = $PSStyle.Foreground.Cyan
199+
$PSStyle.FileInfo.Extension['.ps1xml'] = $PSStyle.Foreground.Cyan
200+
$PSStyle.FileInfo.Extension['.psd1'] = $PSStyle.Foreground.Cyan
201+
$PSStyle.FileInfo.Extension['.psm1'] = $PSStyle.Foreground.Cyan
202+
```
188203
189204
## Cmdlets that generate ANSI output
190205

reference/7.5/Microsoft.PowerShell.Core/About/about_ANSI_Terminals.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the features of PowerShell that use ANSI escape sequences and the terminal hosts that support them.
33
Locale: en-US
4-
ms.date: 08/27/2024
4+
ms.date: 12/09/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.5&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_ANSI_Terminals
@@ -183,8 +183,23 @@ The following members control how or when ANSI formatting is used:
183183
- **SymbolicLink** - Built-in member to specify color for symbolic links
184184
- **Executable** - Built-in member to specify color for executables.
185185
- **Extension** - Use this member to define colors for different file
186-
extensions. The **Extension** member pre-includes extensions for archive
187-
and PowerShell files.
186+
extensions. The **Extension** member predefines colors for archive and
187+
PowerShell file extensions.
188+
189+
The following example shows how to change the colors for various `FileInfo`
190+
settings and specific file extensions. The colors are chosen to work well
191+
on a light terminal background.
192+
193+
```powershell
194+
$PSStyle.FileInfo.Directory = $PSStyle.Background.FromRgb(0x2f6aff) +
195+
$PSStyle.Foreground.BrightWhite
196+
$PSStyle.FileInfo.SymbolicLink = $PSStyle.Foreground.Cyan
197+
$PSStyle.FileInfo.Executable = $PSStyle.Foreground.BrightMagenta
198+
$PSStyle.FileInfo.Extension['.ps1'] = $PSStyle.Foreground.Cyan
199+
$PSStyle.FileInfo.Extension['.ps1xml'] = $PSStyle.Foreground.Cyan
200+
$PSStyle.FileInfo.Extension['.psd1'] = $PSStyle.Foreground.Cyan
201+
$PSStyle.FileInfo.Extension['.psm1'] = $PSStyle.Foreground.Cyan
202+
```
188203
189204
## Cmdlets that generate ANSI output
190205

reference/7.6/Microsoft.PowerShell.Core/About/about_ANSI_Terminals.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Describes the features of PowerShell that use ANSI escape sequences and the terminal hosts that support them.
33
Locale: en-US
4-
ms.date: 08/27/2024
4+
ms.date: 12/09/2025
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.6&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_ANSI_Terminals
@@ -183,8 +183,23 @@ The following members control how or when ANSI formatting is used:
183183
- **SymbolicLink** - Built-in member to specify color for symbolic links
184184
- **Executable** - Built-in member to specify color for executables.
185185
- **Extension** - Use this member to define colors for different file
186-
extensions. The **Extension** member pre-includes extensions for archive
187-
and PowerShell files.
186+
extensions. The **Extension** member predefines colors for archive and
187+
PowerShell file extensions.
188+
189+
The following example shows how to change the colors for various `FileInfo`
190+
settings and specific file extensions. The colors are chosen to work well
191+
on a light terminal background.
192+
193+
```powershell
194+
$PSStyle.FileInfo.Directory = $PSStyle.Background.FromRgb(0x2f6aff) +
195+
$PSStyle.Foreground.BrightWhite
196+
$PSStyle.FileInfo.SymbolicLink = $PSStyle.Foreground.Cyan
197+
$PSStyle.FileInfo.Executable = $PSStyle.Foreground.BrightMagenta
198+
$PSStyle.FileInfo.Extension['.ps1'] = $PSStyle.Foreground.Cyan
199+
$PSStyle.FileInfo.Extension['.ps1xml'] = $PSStyle.Foreground.Cyan
200+
$PSStyle.FileInfo.Extension['.psd1'] = $PSStyle.Foreground.Cyan
201+
$PSStyle.FileInfo.Extension['.psm1'] = $PSStyle.Foreground.Cyan
202+
```
188203
189204
## Cmdlets that generate ANSI output
190205

reference/docs-conceptual/learn/shell/using-light-theme.md

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: >
33
This article shows how to configure PSReadLine color settings for a light themed terminal.
4-
ms.date: 11/21/2025
4+
ms.date: 12/09/2025
55
title: Configuring a light colored theme
66
---
77
# Configuring a light colored theme
@@ -11,6 +11,14 @@ terminal. However, some users might choose to use a light background with dark t
1111
the default colors don't set the background, using light foreground colors on a light background
1212
produces unreadable text.
1313

14+
Beginning in PowerShell 7.2, PowerShell adds colorized output to the default console experience. The
15+
`$PSStyle` feature is not natively available in Windows PowerShell. However, using the [PSStyle][05]
16+
module from the PowerShell Gallery, you can set color values using these same techniques described
17+
in this article.
18+
19+
The colors used are defined in the `$PSStyle` variable and are designed for a dark background. You
20+
can change these colors to work better for a light background terminal.
21+
1422
**PSReadLine** allows you to define colors for 18 different syntax elements. You can view the
1523
current settings using the `Get-PSReadLineOption` cmdlet.
1624

@@ -96,13 +104,9 @@ $ISETheme = @{
96104
```
97105

98106
> [!NOTE]
99-
> In PowerShell 7.2 and higher you can use the `FromRGB()` method of `$PSStyle` to create the ANSI
100-
> escape sequences for the colors you want.
101-
>
102-
> For more information about `$PSStyle`, see [about_ANSI_Terminals][01].
103-
>
104-
> For more information about ANSI escape sequences, see the [ANSI escape code][04] article in
105-
> Wikipedia.
107+
> You can use the `FromRGB()` method to create the ANSI escape sequences for the colors you want.
108+
> For more information about `$PSStyle`, see [about_ANSI_Terminals][01]. For more information about
109+
> ANSI escape sequences, see the [ANSI escape code][04] article in Wikipedia.
106110
107111
## Setting the color theme in your profile
108112

@@ -116,38 +120,36 @@ Add the `$ISETheme` variable and the following `Set-PSReadLineOption` command to
116120
Set-PSReadLineOption -Colors $ISETheme
117121
```
118122

119-
Beginning in PowerShell 7.2, PowerShell adds colorized output to the default console experience. The
120-
colors used are defined in the `$PSStyle` variable and are designed for a dark background. The
121-
following settings work better for a light background terminal.
123+
The following settings work better for a light background terminal.
122124

123125
```powershell
124-
$PSStyle.Formatting.FormatAccent = "`e[32m"
125-
$PSStyle.Formatting.TableHeader = "`e[32m"
126-
$PSStyle.Formatting.ErrorAccent = "`e[36m"
127-
$PSStyle.Formatting.Error = "`e[31m"
128-
$PSStyle.Formatting.Warning = "`e[33m"
129-
$PSStyle.Formatting.Verbose = "`e[33m"
130-
$PSStyle.Formatting.Debug = "`e[33m"
131-
$PSStyle.Progress.Style = "`e[33m"
126+
$PSStyle.Formatting.FormatAccent = $PSStyle.Foreground.Green
127+
$PSStyle.Formatting.TableHeader = $PSStyle.Foreground.Green
128+
$PSStyle.Formatting.ErrorAccent = $PSStyle.Foreground.Cyan
129+
$PSStyle.Formatting.Error = $PSStyle.Foreground.Red
130+
$PSStyle.Formatting.Warning = $PSStyle.Foreground.Yellow
131+
$PSStyle.Formatting.Verbose = $PSStyle.Foreground.Yellow
132+
$PSStyle.Formatting.Debug = $PSStyle.Foreground.Yellow
133+
$PSStyle.Progress.Style = $PSStyle.Foreground.Yellow
132134
$PSStyle.FileInfo.Directory = $PSStyle.Background.FromRgb(0x2f6aff) +
133135
$PSStyle.Foreground.BrightWhite
134-
$PSStyle.FileInfo.SymbolicLink = "`e[36m"
135-
$PSStyle.FileInfo.Executable = "`e[95m"
136-
$PSStyle.FileInfo.Extension['.ps1'] = "`e[36m"
137-
$PSStyle.FileInfo.Extension['.ps1xml'] = "`e[36m"
138-
$PSStyle.FileInfo.Extension['.psd1'] = "`e[36m"
139-
$PSStyle.FileInfo.Extension['.psm1'] = "`e[36m"
136+
$PSStyle.FileInfo.SymbolicLink = $PSStyle.Foreground.Cyan
137+
$PSStyle.FileInfo.Executable = $PSStyle.Foreground.BrightMagenta
138+
$PSStyle.FileInfo.Extension['.ps1'] = $PSStyle.Foreground.Cyan
139+
$PSStyle.FileInfo.Extension['.ps1xml'] = $PSStyle.Foreground.Cyan
140+
$PSStyle.FileInfo.Extension['.psd1'] = $PSStyle.Foreground.Cyan
141+
$PSStyle.FileInfo.Extension['.psm1'] = $PSStyle.Foreground.Cyan
140142
```
141143

142144
## Choosing colors for accessibility
143145

144146
The ISE color theme might not work for users with color-blindness or other conditions that limit
145147
their ability to see colors.
146148

147-
The [World Wide Web Consortium (W3C)][05] has recommendations for using colors for accessibility.
149+
The [World Wide Web Consortium (W3C)][06] has recommendations for using colors for accessibility.
148150
The Web Content Accessibility Guidelines (WCAG) 2.1 recommends that "visual presentation of text and
149151
images of text has a contrast ratio of at least 4.5:1." For more information, see
150-
[Success Criterion 1.4.3 Contrast (Minimum)][06].
152+
[Success Criterion 1.4.3 Contrast (Minimum)][07].
151153

152154
The [Contrast Ratio][03] website provides a tool that lets you pick foreground and background
153155
colors and measure the contrast. You can use this tool to find color combinations that work best for
@@ -158,5 +160,6 @@ you.
158160
[02]: creating-profiles.md
159161
[03]: https://contrast-ratio.com/
160162
[04]: https://en.wikipedia.org/wiki/ANSI_escape_code
161-
[05]: https://www.w3.org/
162-
[06]: https://www.w3.org/TR/WCAG/#contrast-minimum
163+
[05]: https://www.powershellgallery.com/packages/PSStyle
164+
[06]: https://www.w3.org/
165+
[07]: https://www.w3.org/TR/WCAG/#contrast-minimum

0 commit comments

Comments
 (0)