问题
Mercurial's color
extension is great and all, but there isn't a list on that page of what the valid colors are. I looked for a python file named color, hoping I'd be able to read the source and see it there, but no luck. I was hoping to use grey or light grey for a color but it wasn't valid. Grey (or gray) seems like a pretty likely color to be in a list of colors.
Where can I find a list of valid colors for the color
extension? Or where can I find the source for the color
extension?
回答1:
You can find the source code at Mercurial Color Extension.
By default, the colors it recognises are black, red, green, yellow, blue, magenta, cyan, white.
But, as you'll see from the source, it's possible to define custom colours, but how you do this will depend on your terminal. Search for brightblue
in the source.
回答2:
The valid - background and foreground - colors depend on the coloring mode mercurial is using. You get the most (?) flexibility when using terminfo coloring, in which case you typically have access to xterm's 256 color cube. This python script by Marius Gedminas will list them all for you on your terminal (it's shell-executable starting with a shebang so you can just execute it directly - on a Unix'ish system). But to save you the trouble, I've linked to the output below.
Before listing all the colors, though, here's a concrete example of how to use that listing in your .hgrc
file:
[extensions]
color =
[color]
mode=terminfo
color.lightgray = 250
color.darkgray = 239
status.modified = darkgray bold lightgray_background
This will produce dark gray text on a lighter gray background (these are not the 'canonical' dark and light gray colors though - those are 007 and 015). Note there's no separate definition for foreground vs background colors - you can just append _background
to a defined color name.
来源:https://stackoverflow.com/questions/11548978/what-are-the-valid-colors-for-mercurials-color-extension