- OpenVPN IPv6 and IPv4 configuration - Mon, Mar 1 2021
- 4sysops author and member competition 2020 - Fri, Jan 1 2021
- Assign an IPv6 address to an EC2 instance (dual stack) - Tue, Dec 15 2020
Colors are a matter of taste. Many of the older geeks prefer a console with a black background and a green foreground color. I suppose it reminds them of the good old days when we only had monochrome computer screens (so-called green screens) and Paul Allen and Steve Wozniak had not yet stolen the GUI technology from Xerox PARC.
Thus, I guess many hardcore console enthusiasts didn't really like it when Microsoft included PSReadLine in PowerShell 5. I already liked the module before that. I like colors. I find syntax highlighting quite helpful for avoiding typos and, in my view, it not only makes sense for scripting but also on a console.
The problem is that when you change the background color of your console (through the console properties), the default PSReadLine colors often don't fit anymore. The good thing is that you can change the default PSReadLine colors, although it is not as straightforward as in modern terminal applications where you can often choose from a wide range of colors in a GUI. The PowerShell console offers only a very limited number of colors. I explained everything in detail in the wiki. Please help improve the document by editing it.
In theory, the Set-PSReadlineOption cmdlet allows you to do more than set the colors of tokens. According to Microsoft's documentation, the cmdlet also supports parameters such as -ContinuationPromptForegroundColor, -ContinuationPromptBackgroundColor, -EmphasisForegroundColor, -EmphasisBackgroundColor, -ErrorForegroundColor, and -ErrorBackgroundColor.
For instance, to set the background color for errors to blue, this command is supposed to make the change:
Set-PSReadlineOption -ErrorBackgroundColor "Blue"
Subscribe to 4sysops newsletter!
In practice, this command didn't work for me. It didn't throw an error message in my test, but it didn't change the colors, either. Maybe I misunderstood something here? Enlighten me please!