question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support 0xRRGGBB colors on Write-Host

See original GitHub issue

Summary of the new feature / enhancement

As a user I want Write-Host to support specifying full RGB colors on the -Foreground and -Background parameters.

I would also like to be able to specify any of the X11 named colors by name

Proposed technical implementation details (optional)

Instead of needing to write $($PSStyle.Foreground.FromRgb(0xa020f0)) into the string to set a purple color, I want to specify -Foreground A020F0 or -Foreground 0xa020f0 or -Foreground Purple

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Jaykulcommented, Mar 20, 2022
  • Should we consider using the Web color names instead of X11 as some of them aren’t the same and is more modern?

Definitely NOT. 😉

For three reasons:

  1. This is the terminal. We are older than the web, and we aim to be compatible with xterm, not mosaic.
  2. The web colors change some of the common names that are part of the existing 16 colors. E.g. cyan became aqua, magenta became fuchsia…
  3. The web colors are sRGB color-space specific, and you don’t have that luxury 😉
1reaction
jhoneillcommented, Feb 26, 2022

@Jaykul FWIW I never said that all use of colour is bad.

However. We teach programmers that the job of programs is to print text on the console (e.g. Hello, World), and even when the programming task is scripting, not systems programming there is still a desire to print WAY too much : - one recent issue is to print the time to process the profile less often: I can judge fast enough or too slow, without knowing to the millisecond how long it took, I’m no more informed by the message being there , so why is it shown by default. Way too much that is printed (like the long hashes in your example) is nothing but chaff that the poor user needs to wade through.

The felony is compounded by Programmers who - with no particular skills in UI design being brought to bear on the problem - decide that we’d like our headings in green, or Zip files picked out in red or some such (or for an example on a recent issue, an external executable prints file names in dark magenta - a problem for Windows PowerShell on the default windows host).
It’s not always bad: git helps me see changes by using of colour, but in the colours git log are just what devs thought was a good idea at the time. Picking out warnings and errors is good, and what you’ve shown basically has two classes of “recede into the background” and one class of “Pay attention to this”. We’re better off with that. But the devs let lose with crayons kind of colouring in is something we should be spared.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write-Host (Microsoft.PowerShell.Utility)
Specifies the text color. There is no default. The acceptable values for this parameter are: Black; DarkBlue; DarkGreen; DarkCyan; DarkRed; DarkMagenta ...
Read more >
Write-Host with background colour fills the entire line ...
1 Answer 1 · 1 - Use Non-Breaking space character space at the end of line. · 2 - Use any character with...
Read more >
PowerShell - How to format Write-Host with multiple colors
PowerShell method allowing to output a string in multiple colors. ... Write-Host "Whole text is in red with background Yellow" -ForegroundColor Red ...
Read more >
Change font color in powershell output? - Uncategorised
I tried script like this but the font color in Ocotpus console is still default: write-host “Hello world!” -foregroundcolor “magenta”.
Read more >
Powershell - write-host color not working
1. Try the following way: write-host -foregroundcolor "green" "Group " $GroupName " Successfully Added to " $Url $sourceFolder · 1. Are you sure ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found