From dd285ef4ba4760bed0d6a3d16109e9f164263862 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Thu, 28 Oct 2021 14:36:51 +0200 Subject: [PATCH] Cleanup Convert-HexToAnsiiEscape --- .../.config/powershell/Microsoft.PowerShell_profile.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 b/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 index c56290b..0af312b 100644 --- a/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 +++ b/powershell/.config/powershell/Microsoft.PowerShell_profile.ps1 @@ -19,11 +19,8 @@ function Convert-HexToAnsiiEscape { param ([Parameter(Mandatory)] [string]$hex) $nohash = $hex.substring(1) - $rgb = $nohash -split '(..)' -ne '' - $r = [Convert]::ToInt64($rgb[0], 16) - $g = [Convert]::ToInt64($rgb[1], 16) - $b = [Convert]::ToInt64($rgb[2], 16) - [char]27 + "$ansi_escape[38;2;{0};{1};{2}m" -f $r, $g, $b + $rgb = $nohash -split '(..)' -ne '' | ForEach-Object { [Convert]::ToInt64($_, 16) } + [char]27 + "$ansi_escape[38;2;{0};{1};{2}m" -f $rgb[0], $rgb[1],$rgb[2] } $Colors = @{