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 colordiff will send most options through to diff, but there are various
90 colordiff-specific options which can be used:
91
92 --help
93 Show these colordiff-specific options
94
95 --color=(yes|no)
96 Force (or suppress) display of colours in output
97
98 --color=patches=(yes|no)
99 Force (or suppress) inclusion of colour codes in patch output
100
101 --color-term-output-only
102 Force colour to only appear in terminal output
103
104 --difftype=DIFFTYPE
105 Force difftype detection to specified format. DIFFTYPE can be:
106 diff, diffc, diffu, diffy, debdiff, wdiff
107
108 --(no)banner
109 Show (or suppress) the colordiff banner
110
112 /etc/colordiffrc
113 Central configuration file. User-specific settings can be enabled
114 by copying this file to ~/.colordiffrc and making the appropriate
115 changes.
116
117 colordiffrc-lightbg
118 Alternate configuration template for use with terminals having
119 light backgrounds. Copy this to /etc/colordiffrc or ~/.colordiffrc
120 and customize.
121
122 colordiffrc-gitdiff
123 Alternate configuration template for use with terminals having dark
124 backgrounds, with colour defaults set to match the output of 'git
125 diff'. Copy this to /etc/colordiffrc or ~/.colordiffrc and
126 customize.
127
129 Bug reports and suggestions/patches to <davee@sungate.co.uk> please.
130
132 Dave Ewart
133 colordiff author and Debian packager
134
135 Graham Wilson
136 Manual page and XML source author
137
138 Colin Tuckley
139 Debian package sponsor
140
141
142
143colordiff 12/22/2022 COLORDIFF(1)