Less is more: colordiff and more or less

In the Unix/Linux/Mac OS X world, less is more. Literally, in that ‘less‘ fully emulates ‘more‘, and figuratively, as it provides useful additional functionality like backwards scrolling. So, you really want to use ‘less’ instead of ‘more’ for paging another command’s output, e.g.

cat a_long_document.txt|less

When used to page the output of colordiff however, ‘less’ displays a mess instead of properly displaying colored output like ‘more’.
The trick is to use ‘less’ with either the -r or -R option (which both repaint the screen), i.e.

colordiff -u file_old.py file_new.py|less -r


colordiff -u file_old.py file_new.py|less -R

(try which one works better with your system and terminal)

2 Replies to “Less is more: colordiff and more or less”

  1. Another good way is to pipe output into vim, especially if it has support for syntax highlighting the text already:

    $ diff -pruN olddir/ newdir/ | vim –

Leave a Reply

Your email address will not be published. Required fields are marked *

11 − 7 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.