Show-ANSISequence
SYNOPSIS
Display ANSI escape sequences
SYNTAX
basic (Default)
Show-ANSISequence [-Basic] [-AsString] [<CommonParameters>]
foreback
Show-ANSISequence [-Foreground] [-Background] [-Type <String>] [-AsString] [<CommonParameters>]
RGB
Show-ANSISequence [-RGB <Int32[]>] [-AsString] [<CommonParameters>]
DESCRIPTION
This script is designed to make it easy to see ANSI escape sequences and how they will display in your PowerShell session. Use the -AsString parameter to write simple strings to the pipeline which makes it easier to copy items to the clipboard.
The escape character will depend on whether you are running Windows PowerShell or PowerShell 7.x. For best results, you need to run this command in a PowerShell session and host that supports ANSI escape sequences.
EXAMPLES
EXAMPLE 1
PS C:\> Show-ANSISequence
*******************
* Basic Sequences *
*******************
`e[9mCrossedOut`e[0m
`e[7mReverse`e[0m
`e[6mRapidBlink`e[0m
`e[5mSlowBlink`e[0m
`e[4mUnderline`e[0m
`e[3mItalic`e[0m
`e[2mFaint`e[0m
`e[1mBold`e[0m
The output will be formatted using the corresponding ANSI escape sequence as seen in PowerShell 7.x.
EXAMPLE 2
PS C:\>Show-ANSISequence -Foreground -Type Simple
**************
* Foreground *
**************
`e[30mHello`e[0m `e[31mHello`e[0m `e[32mHello`e[0m
`e[34mHello`e[0m `e[35mHello`e[0m `e[36mHello`e[0m
`e[90mHello`e[0m `e[91mHello`e[0m `e[92mHello`e[0m
`e[94mHello`e[0m `e[95mHello`e[0m `e[96mHello`e[0m
EXAMPLE 3
PS C:\> Show-ANSISequence -RGB 225,100,50
`e[38;2;225;100;50m256 Color (R:225)(G:100)(B:50)`e[0m
Show an RGB ANSI sequence. The output will be formatted using the sequence.
EXAMPLE 4
PS C:\> Show-ANSISequence -RGB 225,100,50 -AsString | Set-Clipboard
Repeat the previous example but write the output as a plain string and copy it to the Windows clipboard.
PARAMETERS
-Basic
Display basic ANSI settings. This is the default output.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: basic
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Foreground
Display foreground ANSI format settings. If you use -Type without specifying -Foreground or -Background, -Foreground will be used by default.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: foreback
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Background
Display background ANSI format settings.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: foreback
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Type
You can display simple ANSI, 8-bit, or all sequences. Valid values are All,Simple and 8bit.
Type: System.String
Parameter Sets: foreback
Aliases:
Required: False
Position: Named
Default value: All
Accept pipeline input: False
Accept wildcard characters: False
-RGB
Display an RGB ANSI sequence. You must pass an array of values for Red,Blue, and Green. Each value must be between 0 and 255.
Type: System.Int32[]
Parameter Sets: RGB
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-AsString
Show the value as an unformatted string.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.