When I do as below with an aliased grep(grep --color=auto)
echo abcde | grep 'ab'
echo abcde | grep 'ab' >foo.txt
grep recognizes where you store the result and disables coloring in case of
auto setting for redirections (colors is enabled only for terminal).
--color=always to force it to use it ... always, but I don't think you will find those control sequences nice to view in a text file.