4

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

$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

4 Comments

you may want to add a note that this requires a console that can use ANSI escape sequences. as an example, the default windows 7 console does not support such. [grin]
I don't even know if I want it
Thanks, this worked! Is there a way to do this for background too? I tried to do something like write-host "`e[7;6;$(60)m[60]" but that resulted in a really weird alternating background.
Can you please explain how this works? In particular the code in the quotes?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.