Comment by theamk
6 years ago
I don't see how this is supposed to work? Let's take "grep" for example -- you want both of these to work, and print color to terminal:
grep box file.txt
grep box file.txt | grep -v orange-box
Having --color=always is nice sometimes, but there is a reason grep has "--color=auto" and it is the default. If we write invisible characters to file, this breaks all sorts of tools, so it is much safer and more predictable to not include them.
If I wanted to see just orange-box, then I would do
But, I don't want to see just orange-box. I want to see orange-box and compare against other cases of box. So I would do:
Without that --color=always, other cases of box will be drowned out by the noise.
And if I wanted to write that out to a file then I would do
Alternatively, I'd add a filter to the file with `ansi2txt`
I think the point the person you are replying to was trying to make is that in your proposed sequence of colored greps, the second one would not catch the "orange-box"es because of the extra chars added for coloring the output of the first grep.
Maybe grep should ignore ansi sequences optionally or by default, to solve this?