PSWriteColorEX

1.1.0

Colored and styled console output for PowerShell: TrueColor (24-bit RGB), ANSI 256 and 16 colors, gradients, text styles, style profiles, padding that counts wide characters, and logging to a file. Pure PowerShell, for Windows PowerShell 5.1 and PowerShell 7 on Windows, Linux and macOS.

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name PSWriteColorEX

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name PSWriteColorEX

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2024 MarkusMcNugen. All rights reserved.

Package Details

Author(s)

  • MarkusMcNugen

Tags

Console Color Colour ANSI Terminal Output Formatting Logging TrueColor RGB CrossPlatform Windows Linux macOS

Functions

Write-ColorEX Write-ColorError Write-ColorWarning Write-ColorInfo Write-ColorSuccess Write-ColorCritical Write-ColorDebug Set-ColorDefault Get-ColorProfiles New-ColorStyle Test-AnsiSupport Convert-HexToRGB Convert-RGBToANSI8 Convert-RGBToANSI4 Get-ColorTableWithRGB Measure-DisplayWidth Get-LighterRGBColor Get-LighterColorName Get-LighterANSI8Color

PSEditions

Desktop Core

Dependencies

This module has no dependencies.

Release Notes

1.1.0

Fixed:
- A transcript (Start-Transcript) records each line as one line, with no blank line after it, and as many blank lines as -LinesBefore and -LinesAfter ask for (issue #2). In Windows PowerShell 5.1 a line of several console colors is still one transcript line per color, as PowerShell records each Write-Host call.
- Every string piped to Write-ColorEX or a Write-Color* helper is written; only the last one was before.
- -LogFile given as a file name alone goes in the calling script's folder, or the current location at the prompt; it went in the module's own folder before. A missing log folder is created.
- -BlankLine works with output redirected, -BackGroundColor 'None' works, -Gradient alone draws the gradient, -Color 0 is black, -Style 'Bold' alone styles the first segment, and text without -Color takes the terminal's default color.
- A gradient keeps emoji whole: each character a terminal draws takes one color.
- Hex colors work without -TrueColor, color names such as Orange keep working after a call without a color mode, and -Bold keeps White text white.
- -ANSI8 color numbers take the nearest of the 16 colors on a 16-color terminal, and -ANSI4 and -ANSI8 numbers the nearest console color where the terminal has no ANSI support.
- [PSColorStyle] can be used after Import-Module, and a change to a style profile applies to its next use.

Changed:
- On PowerShell 7.2 and later, where escape codes reach the screen, each line goes to the host in one Write-Host call.
- Log files are UTF-8 without a byte order mark by default, and each -Encoding name writes the same bytes in Windows PowerShell 5.1 and PowerShell 7.
- Measure-DisplayWidth uses the table of the Rust crate unicode-width 0.2.2 and the emoji sequence rules terminals follow, with the same widths in 5.1 and 7. Characters such as a filled circle and box drawing are 1 cell, 2 with -AmbiguousAsWide.
- Importing the module prints nothing.
- Lighten-RGBColor, Lighten-ColorName and Lighten-ANSI8Color are Get-LighterRGBColor, Get-LighterColorName and Get-LighterANSI8Color, with the old names as aliases.

Added:
- TERM=dumb turns colors off, Windows Terminal under WSL is detected as TrueColor, and -Encoding takes utf8BOM, utf8NoBOM, bigendianutf32 and ansi.

The full list is in CHANGELOG.md: https://github.com/MarkusMcNugen/PSWriteColorEX/blob/main/CHANGELOG.md

FileList

Version History

Version Downloads Last updated
1.1.0 (current version) 5 10/6/2026