Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom font color for Powershell output

Let's take the powershell command Write-Host "red text" -Fore red this displays "red text" in a foreground of red.
But, you want the text to be displayed in a slightly lighter font color, light red.

Is there a way to do this and get any foreground color (and background) in the RGB spectrum using powershell?

like image 467
Kudos Avatar asked Oct 31 '25 09:10

Kudos


2 Answers

See this: https://github.com/PoshCode/Pansies
It is a PowerShell module that does this. There is an issue here related to your question: https://github.com/PowerShell/PowerShell/issues/14588
Please click the above link for more information.

like image 108
AdamJane23 Avatar answered Nov 02 '25 02:11

AdamJane23



$PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      1      0

(0..256).ForEach{write-host "`e[38;5;$($_)m[$_]"} # background color
(0..256).ForEach{write-host "`e[48;5;$($_)m[$_]"} # Foreground color

like image 45
Алексей Семенов Avatar answered Nov 02 '25 04:11

Алексей Семенов



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!