1COLORDIFF(1) User Commands COLORDIFF(1)
2
3
4
6 colordiff - a tool to colorize diff output
7
9 colordiff [diff options] [colordiff options] {file1} {file2}
10
12 colordiff is a wrapper for diff and produces the same output as diff
13 but with coloured syntax highlighting at the command line to improve
14 readability. The output is similar to how a diff-generated patch might
15 appear in Vim or Emacs with the appropriate syntax highlighting options
16 enabled. The colour schemes can be read from a central configuration
17 file or from a local user ~/.colordiffrc file.
18
19 colordiff makes use of ANSI colours and as such will only work when
20 ANSI colours can be used - typical examples are xterms and Eterms, as
21 well as console sessions.
22
23 colordiff has been tested on various flavours of Linux and under
24 OpenBSD, but should be broadly portable to other systems.
25
27 Use colordiff wherever you would normally use diff, or instead pipe
28 output to colordiff:
29
30 For example:
31
32 $ colordiff file1 file2
33 $ diff -u file1 file2 | colordiff
34
35 You can pipe the output to 'less', using the '-R' option (some systems
36 or terminal types may get better results using '-r' instead), which
37 keeps the colour escape sequences, otherwise displayed incorrectly or
38 discarded by 'less':
39
40 $ diff -u file1 file2 | colordiff | less -R
41
42 If you want to force disable colour escape sequences (for example pipe
43 the output to patch), you can use option '--color=no' to do so:
44
45 $ diff -u file1 file2 | colordiff --color=no | patch -p0 -d another-working-dir
46
47 If you have wdiff installed, colordiff will correctly colourise the
48 added and removed text, provided that the '-n' option is given to
49 wdiff:
50
51 $ wdiff -n file1 file2 | colordiff
52
53 You may find it useful to make diff automatically call colordiff. Add
54 the following line to ~/.bashrc (or equivalent):
55
56 alias diff=colordiff
57
58 Any options passed to colordiff are passed through to diff except for
59 the colordiff-specific option 'difftype', e.g.
60
61 colordiff --difftype=debdiff file1 file2
62
63 Valid values for 'difftype' are: diff, diffc, diffu, diffy, wdiff,
64 debdiff; these correspond to plain diffs, context diffs, unified diffs,
65 side-by-side diffs, wdiff output and debdiff output respectively. Use
66 these overrides when colordiff is not able to determine the diff-type
67 automatically.
68
69 Alternatively, a construct such as 'cvs diff SOMETHING | colordiff' can
70 be included in ~/.bashrc as follows:
71
72 function cvsdiff () { cvs diff $@ | colordiff; }
73
74 Or, combining the idea above using 'less':
75
76 function cvsdiff () { cvs diff $@ | colordiff |less -R; }
77
78 Note that the function name, cvsdiff, can be customized.
79
80 By default colordiff returns the exit code of the underlying diff
81 invocation (if there is one), but there are some circumstances where it
82 is useful to force colordiff's exit code to be zero: to do this use the
83 option '--fakeexitcode':
84
85 colordiff --fakeexitcode ...
86
87
89 /etc/colordiffrc
90 Central configuration file. User-specific settings can be enabled
91 by copying this file to ~/.colordiffrc and making the appropriate
92 changes.
93
94 colordiffrc-lightbg
95 Alternate configuration template for use with terminals having
96 light backgrounds. Copy this to /etc/colordiffrc or ~/.colordiffrc
97 and customize.
98
99 colordiffrc-gitdiff
100 Alternate configuration template for use with terminals having dark
101 backgrounds, with colour defaults set to match the output of 'git
102 diff'. Copy this to /etc/colordiffrc or ~/.colordiffrc and
103 customize.
104
106 Bug reports and suggestions/patches to davee@sungate.co.uk please.
107
109 Dave Ewart
110 colordiff author and Debian packager
111
112 Graham Wilson
113 Manual page and XML source author
114
115 Colin Tuckley
116 Debian package sponsor
117
118
119
120colordiff 05/21/2015 COLORDIFF(1)