Colors – Can Less Retain Colored Output?

colorsless

Can I get less not to monochrome its output?

E.g., the output from git diff is colored, but git diff | less is not.

Best Answer

Use:

git diff --color=always | less -r

--color=always is there to tell git to output color codes even if the output is a pipe (not a tty). And -r is there to tell less to interpret those color codes and other escape sequences. Use -R for ANSI color codes only.