The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ccdiff - Colored character diff

SYNOPSIS

 ccdiff [options] file1|- file2|-

 ccdiff --help
 ccdiff --man
 ccdiff --info

DESCRIPTION

OPTIONS

Command line options

--help -?

Show a summary op the available command-line options and exit.

--version -V

Show the version and exit.

--man

Show this manual using pod2man and nroff.

--info

Show this manual using pod2text.

--utf-8 -U

All I/O (streams to compare and standard out) are in UTF-8.

--unified[=3] -u [3]

Generate a unified diff. The number of context lines is optional. When omitted it defaults to 3. Currently there is no provision of dealing with overlapping diff chunks. If the common part between two diff chunks is shorter than twice the number of context lines, some lines may show twice.

The default is to use traditional diff:

 5,5c5,5
 < Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
 ---
 > Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539

a unified diff (-u1) would be

 5,5c5,5
   Tue Sep  6 05:43:59 2005,B.O.Q.S.,,1125978239,1943341
 - Sat Dec 18 07:00:33 1993,I.O.D.U.,,756194433,1442539
 + Sat Dec 18 07:08:33 1998,I.O.D.U.,,756194433,1442539
   Mon Feb 23 10:37:02 2004,R.X.K.S.,van,1077529022,1654127
--verbose[=1] -v[1]

Show an additional line for each old or new section in a change chunk (not for added or deleted lines) that shows the hexadecimal value of each character. If --utf-8 is in effect, it will show the Unicode character name(s).

This is a debugging option, so invisible characters can still be "seen".

--verbose accepts an optional verbosity-level, but no specific behavior for these have not yet been defined.

--color -c

Use colors to show differences. As this is the default, use --no-color or --fancy to use markers instead of color indicators.

--no-color is especially useful if the terminal does not support colors, or if you want to copy/paste the output to (ASCII) mail.

--pink -p

Change the default red for deleted text to the color closest to pink that is supported by Term::ANSIColor: magenta.

--fancy -f

Use (colored) Unicode indicators under changed text instead of the default ^.

I did consider using U+034e (COMBINING UPWARDS ARROW BELOW), but as most terminals are probably unable to show it, I did not pursue the idea.

--reverse -r

Reverse the foreground and background for the colored indicators.

If the foreground color has bold, it will be stripped from the new background color.

--list-colors

List available colors and exit.

--old=color

Define the foreground color for deleted text.

--new=color

Define the foreground color for added text.

--bg=color

Define the background color for changed text.

--index --idx -I

Prefix position indicators with an index.

If a positive number is passed (--index=4 or -I 4), display just the chunk with that index. This is useful in combination with --verbose.

--ignore-case -i

Ignore case on comparison.

--ignore-all-space -w

Ignore all white-space changes. This will set all options -b, -Z, -E, and -B.

--ignore-trailing-space -Z

Ignore changes in trailing white-space (TAB's and spaces).

--ignore-ws|ignore-space-change -b

Ignore changes in horizontal white-space (TAB's and spaces). This does not include white-space changes that splits non-white-space or removes white-space between two non-white-space elements.

--ignore-tab-expansion -E

NYI

--ignore-blank-lines -B

Just Partly Implemented (WIP)

Configuration files

In order to be able to overrule the defaults set in ccdiff, one can set options specific for this login. The following option files are looked for in this order:

 - $HOME/ccdiff.rc
 - $HOME/.ccdiffrc
 - $HOME/.config/ccdiff

and evaluated in that order. Any options specified in a file later in that chain will overwrite previously set options.

Option files are only read and evaluated if it is not empty and not writeable by others than the owner.

The syntax of the file is one option per line. where leading and trailing white-space is ignored. If that line then starts with one of the options listed below, followed by optional white-space followed by either an = or a :, followed by optional white-space and the values, the value is assigned to the option. The values no and false (case insensitive) are aliases for 0. The values yes and true are aliases to -1 (-1 being a true value).

Between parens is the corresponding command-line option.

color (-c)
 color   : true

defines if colors should be used. The default is to use colors. The -c command line option will toggle the option when set from a configuration file.

reverse (-r)
 reverse : false

defines if changes are displayed as foreground-color over background-color or background-color over foreground-color. The default is false, so it will color the changes withe the appropriate color (new or old) over the default background color.

new (--new)
 new     : green

defines the color to be used for added text. The default is green.

any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. This option can include bold either as prefix or as suffix.

This option may also be specified as

 new-color
 new_color
 new-colour
 new_colour
old (--old)
 old     : red

defines the color to be used for delete text. The default is red.

any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. This option can include bold either as prefix or as suffix.

This option may also be specified as

 old-color
 old_color
 old-colour
 old_colour
bg (--bg)
 bg      : white

defines the color to be used as background for changed text. The default is white.

any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning. The bold attribute is not allowed.

This option may also be specified as

 bg-color
 bg_color
 bg-colour
 bg_colour
 background
 background-color
 background_color
 background-colour
 background_colour
verbose
 verbose : cyan

defines the color to be used as color for the verbose tag. The default is cyan. This color will only be used under --verbose.

any color accepted by Term::ANSIColor is allowed. Any other color will result in a warning.

This option may also be specified as

 verbose-color
 verbose_color
 verbose-colour
 verbose_colour
utf8 (-U)
 utf8    : yes

defines whether all I/O is to be interpreted as UTF-8. The default is no.

This option may also be specified as

 unicode
 utf
 utf-8
index (-I)
 index   : no

defines if the position indication for a change chunk is prefixed with an index number. The default is no. The index is 1-based.

Without this option, the position indication would be like

 5,5c5,5
 19,19d18
 42a42,42

with this option, it would be

 [001] 5,5c5,5
 [002] 19,19d18
 [005] 42a42,42

When this option contains a positive integer, ccdiff will only show diff the diff chunk with that index.

SEE ALSO

Algorithm::Diff, Text::Diff

AUTHOR

H.Merijn Brand

COPYRIGHT AND LICENSE

 Copyright (C) 2018-2018 H.Merijn Brand.  All rights reserved.

This library is free software; you can redistribute and/or modify it under the same terms as Perl itself.