How can I make grep respects colors on a pipe?

Solution 1:

You can tell ls to always color the output, since when it's writing to a pipe with --color=auto it does not add color.

If you do ls --color=always path | grep --color=never foo it will make ls add color, and prevent grep from replace with its own colors.