Is it possible to change Clang's choice of colors for their colorized diagnostics?
I like my terminal to have a black background, but I just noticed that I was missing Clang's helpful diagnostic messages. I'm aware of the the -fno-color-diagnostics compiler option but I would prefer to have the colors, just different colors. Any solutions?
I'm using a bash shell in OSX. Thanks.
It looks like the colors are hard-coded near the beginning of this file (include file). You can edit the file and recompile the program, write and submit a feature that accepts color settings at the command line, in an environment variable or from a file, or non-portably try to substitute the colors on the fly.
Here is an example of the latter:
clang ... | sed 's/\o33\[30m/\o33[37m/g'
That changes black to white for XTerm escape sequences. Some other sequence would need to be used for other terminal types.
Related
I want to produce coloured output from a terminal program. My problem is that some people use a 'light' terminal theme, while others use a 'dark' one.
Is there a standard way of ensuring that my output will be readable for all "reasonable" terminal configurations (for some definition of reasonable)?
Consider the following command:
go tool cover -html=coverage.out
Is there a way to make the resulting HTML dark on light (rather than the default light characters on dark background)?
I did not find anything about this neither in the documentation nor in the help pages referenced therein (go tool cover --help and go help testflag)
Not with the built-in tool. There's nothing preventing you from piping the output through some script to change CSS colors, though, or to reference an external CSS file that sets the colors you prefer.
As mentioned by #Flimzy, this is not supported with the built-in tool.
Though, looking at the coverage.html file output by the cover tool.
You can do something like this:
go tool cover -o coverage.html -html=coverage.out; sed -i 's/black/whitesmoke/g' coverage.html; sensible-browser coverage.html
which will write the output to coverage.html using the -o flag and then use sed to change occurrences of black to whitesmoke. It will then use your default browser to open the file.
Note #1: Obviously, this will not work once the tool is updated not to output black color background. Though, if this changes, there is probably a lot better support for different color schemes.
Note #2: If you use heat maps -covermode=count, the light green might look awkward on the smokewhite color. Feel free to try different color accents though.
I'm using the output of the excellent package icdiff (https://github.com/jeffkaufman/icdiff) to check for differences between updated iterations of files. I'd like to parse out just the significant differences though. From the package --help I can't see any in-built options (and for full disclosure I've 'cross posted' at the github issues page to see if it can be added or I've missed something).
This has got me wondering whether a hacky solution might be to parse out the lines by their colour, since they are also colour coded by 'severity of difference'. Is this at all possible in bash? (Alternative approaches are welcome too!)
Here's a sample of the output (I can only think to add a picture here since the markup wouldnt show colour). I'd like to get just the lines where the whole line is solid red/green for instance. Excuse some of the screen wrapping, my monitor isn't wide enough and the text is small enough already.
with GNU Grep, for example
grep -Po $'\e\[31m\K.*(?=\e\[\d+m)'
to extract text in red,
\K to keep the left outside match, like a lookbehind
(?=..) lookahead assertion 0 length match
you can grep on the ANSI escape sequences, e.g. (with 31 for red):
grep '^[\[31m' # make the escape character (^[) by typing ctrl+v ESC
but you need to make sure your output stays colored if it is not sent to a terminal : (many programs will make their output B&W when output is not a terminal. - you can check it with less, which will show you the escape sequences)
on OSX, when I run top sometimes I see some different colors, namely black text....
What does it mean?
What bash setting do I need to change to make these a different color? black is too hard to read with my setup.
It turns out that it was a simple text color in the terminal preferences, I think the title of the setting was 'bold text'
I am using Bash on WebFaction (web hosting) and would like to change my terminal to default to a different background color than black (probably white, but I'd like to play around with it). How do I do this?
I tried doing this:
cp /etc/DIR_COLORS ~/.dir_colors
(edit .dir_colors)
But I could only find the foreground and background colors for various directories and file types, not a global one. Where should I look?
Sorry, you don't have to do it with Bash. Check your terminal emulator display properties.
Note: The shell (Bash in your case) can change the text and background color, but the property can be lost or changed by further ANSI color codes invocations.