@lzybkr bkr added a gist adding coloring formatdata for MatchInfo.
I played a bit with it and added coloring of regex groups and after having used it for a few months, I have to say that it is very useful. Instead of a wall of text, it is really easy to distinguish the things you're looking for.
How about making some version of this ship with the platform?
Looks superb!
We must help our eyes.
It would be nice to paint all output.
Maybe make the individual format color views for other types?
Most won't notice, but there is a small issue that we should consider in the formatting engine before using color in any default formatting.
If you change your foreground/background colors, the "reset color" ANSI escape sequence (CSI 0 m) doesn't work as expected. For example, I have the following in my profile (using my unpublished module ConsoleUtilities)
Import-Module -Name ConsoleUtilities
Set-ConsoleColorTable -ColorTable @{
Black = '#141414'
Blue = '#004bff'
Cyan = '#00ffff'
DarkBlue = '#374b80'
DarkCyan = '#008080'
DarkGray = '#808080'
DarkGreen = '#008000'
DarkMagenta = '#800080'
DarkRed = '#C81010'
DarkYellow = '#808000'
Gray = '#c0c0c0'
Green = '#00ff00'
Magenta = '#ff00ff'
Red = '#ff0000'
White = '#ffffff'
Yellow = '#ffff00'
} -TextForegroundColor Gray -TextBackgroundColor Black
If I start PowerShell from the regular shortcut that has the royal blue background, my suggested implementation for highlighting matches causes weird things to happen.
I'm not sure if this issue should be considered a PowerShell bug or conhost bug, but I do think PowerShell needs to provide a good experience for folks that customize their consoles like I do.
And how should we think about the new console with full RGB support?
Seems wrong to limit ourselves to the small set of named console colors.
Should there be a set of named, configurable, 'highlight' colors?
They could be configured to work well on what is shipping out of the box, but tweakers could set them according to their preferences.
Discussion about color support is in https://github.com/PowerShell/PowerShell/issues/2381
I saw this recently https://twitter.com/LincolnAtkinson/status/907708171728257024 (Code here) and it's related.
It couldn't be just formatting because it changes the output and has multiple lines, but it does go usefully further in explaining how the group names match up against the input test.
e.g. Select-String could get an -ExplainMatch switch which makes it take the first match and output something like this.
I'm at HackIllinois right now and I'd like to take a look at this issue.
Get this out the door. Color highlighting with Select-String should have been included from the beginning. Please Please make this a priority!
This is the top hit in Google when searching: "select-string highlighting" https://copdips.com/2018/05/grep-like-powershell-colorful-select-string.html
@iSazonov the emphasis logic was merged, can this issue be closed?