On Wed, 19 Apr 2017 17:39:36 -0700 wrote: > In any situation where the output of "diff --color" is subjected to > further processing, colour-escaped text which spans multiple lines > will cause a problem, if either the first or last line of the block is > somehow removed or hidden, as with "less". The solution is to repeat > the escape sequences before and after each newline: > > first line of block\n > second line of block\n > third line of block\n For now, this works much better than "diff --color": cdiff() { diff "$@" | sed -e '/^\(---\|+++\)/s/.*/\c[\[1m&\c[\[0m/' \ -e '/^[@0-9]/s/.*/\c[\[36m&\c[\[0m/' \ -e '/^[-<]/s/.*/\c[\[31m&\c[\[0m/' \ -e '/^[+>]/s/.*/\c[\[32m&\c[\[0m/' } cdiff -u file.c~ file.c | less -R The attached images illustrate the differences in output: diff --color=always -u file.c~ file.c | less # diff-color-less.png cdiff -u file.c~ file.c | less # diff-sed-less.png It seems like the problem would be solved completely, if the output of "diff --color" was changed to this form. -- Ian Bruce