Re: coloring rcsdiff output

Colin Brough <[email protected]> Tue, 13 Nov 2018 16:02:40 +0000
Newsgroups gmane.comp.gnu.rcs
Message-ID <[email protected]>
On 13/11/2018 10:30, gregory guy wrote:
> Hi,
> 
> 
> I've been struggling for some time to get a colorized output in ma 
> console with rcsdiff, does anyone know a way to do that?
> 
> It's so much easier to read the differences in a file when there's colors.
> 
> Can this be implemented in a next release too?

To do something similar using a graphical diff program, I have a
script which wraps round the other RCS tools to achieve what I what.
Since there is a 'colordiff' program out there, you could do the same.

My script is below - the graphical diff is 'meld', so just replace
that with 'colordiff' and you'll be a good bit of the way there...

Not polished, not perfect, but works for me.....

HTH

Colin



#!/bin/bash -
#----------------------------------------------------------------------
# rcsmeld	Script to do visual diff on RCS files, diffing from a
#		previous version.
#----------------------------------------------------------------------

VERSION=''

if [ $# -eq 1 ]
then
     FILE=$1
elif [ $# -eq 2 ]
then
     FILE=$2
     VERSION=$1
else
     echo "Usage: rcsmeld [ Version ] File"
     exit 0
fi

#----------------------------------------------------------------------
# This bit allows there to be more than one instance of rcsmeld
# running in a directory at a time. The while loop finds the first
# .xxdiff file that doesn't already exist, then uses it.

i=1
TARGET=.xxdiff$i
while [ -f $TARGET ]
do
     i=$[ $i + 1 ]
     TARGET=.xxdiff$i
done

#----------------------------------------------------------------------
# Now actually get the previous version and compare it to the current
# version, and clean up afterwards.

co -p$VERSION $FILE > $TARGET

meld $FILE $TARGET

rm -f $TARGET

exit 0




-- 

Cheers

Colin

----------------------------------------------------------------------
Colin Brough                             [email protected]