-join (1..255 | % { "`e[48;5;$($_)m {0:00#} `e[0m" -f $_ + ($_ % 15 -eq 0 ? "`n" : " ") })
-join (1..255 | % { "`e[48;5;$($_)m {0:00#} `e[0m" -f $_ + ($_ % ($host.ui.RawUI.WindowSize.Width / 10) -eq 0 ? "`n" : " ") })
#Windows Powershell compatible version
-join (1..255 | % { "$([char]27)[48;5;$($_)m {0:00#} $([char]27)[0m" -f $_;if ($_ % ($host.ui.RawUI.WindowSize.Width / 10) -eq 0) { "`n" } else { " " } })
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update-TypeData -TypeName '_RegexAnsi' -MemberType ScriptMethod -MemberName ToString -Force -Value { | |
return ($this.Value ? $this.value : $this.Text) | |
} | |
Update-TypeData -TypeName '_IsDecorated' -MemberType ScriptMethod -MemberName ToString -Force -Value { | |
return $this.IsDecorated | |
} | |
function Get-AnsiEscape { | |
<# | |
.DESCRIPTION | |
Get-AnsiEscape can be used to strip, escape, or regex VT codes from a string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-TableFormat { | |
<# | |
.SYNOPSIS | |
Rebuild an object based on the Format Data for the object. | |
.DESCRIPTION | |
Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject. | |
#> | |
[CmdletBinding()] | |
param ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
yoinked and just stripped the namespace and change internal to public | |
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/utils/FuzzyMatch.cs | |
https://www.geeksforgeeks.org/damerau-levenshtein-distance/ | |
https://yassineelkhal.medium.com/the-complete-guide-to-string-similarity-algorithms-1290ad07c6b7 | |
#> | |
Add-Type -TypeDefinition @' | |
// Copyright (c) Microsoft Corporation. | |
// Licensed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EncodingAttribute : System.Management.Automation.ArgumentTransformationAttribute { | |
[object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) { | |
if ( $inputData -is [string] ) { | |
return [Text.Encoding]::GetEncoding($inputData) | |
} else { | |
return $inputData | |
} | |
} | |
} |
NewerOlder