2

Is it possible to retain the color while storing the diff output in a file?

This is working and showing the colors in terminal

colordiff -yW 1000 --suppress-common-lines file1 file2 > tempfile

But when I redirect the output to a file its not showing the colors.

colordiff -yW 1000 --suppress-common-lines file1 file2 > tempfile
1
2

If you always want color, modify your configuration file /etc/colordiffrc or ~/.colordiffrc as per the comment in the default file:

# By default, when colordiff output is being redirected
# to a file, it detects this and does not colour-highlight
# To make the patch file *include* colours, change the option
# below to 'yes'
color_patches=no
0

Try opening tempfile in vim. When I do this, vim colors it just as I see in the terminal output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.