View | Details | Raw Unified | Return to bug 75310
Collapse All | Expand All

(-)cdiff/src/cdiff.1 (+6 lines)
Lines 34-39 Link Here
34
.Nd show diffs with colors
34
.Nd show diffs with colors
35
.Sh SYNOPSIS
35
.Sh SYNOPSIS
36
.Nm cdiff
36
.Nm cdiff
37
.Op Fl m
37
.Op Ar diff ...
38
.Op Ar diff ...
38
.Sh DESCRIPTION
39
.Sh DESCRIPTION
39
.Nm
40
.Nm
Lines 43-48 Link Here
43
.Xr less 1 .
44
.Xr less 1 .
44
If used on a color terminal, it makes diffs much easier to read.
45
If used on a color terminal, it makes diffs much easier to read.
45
There is also handling of "cvs annotate" in it.
46
There is also handling of "cvs annotate" in it.
47
.Pp
48
.Bl -tag -width Ds
49
.It Fl m
50
Use bold, reverse and underline codes (for monochrome terminals).
51
.El
46
.Sh AUTHORS
52
.Sh AUTHORS
47
.Nm
53
.Nm
48
was written by
54
was written by
(-)cdiff/src/cdiff.sh (-9 / +16 lines)
Lines 1-4 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
if [ "$1" = "-m" ]; then
3
	shift;
4
	CODES="4:7:1:1"
5
else
6
	CODES="1:34:31:35"
7
fi
2
(if [ "$1" != "" ]; then
8
(if [ "$1" != "" ]; then
3
    while [ "$1" != "" ]; do
9
    while [ "$1" != "" ]; do
4
    	case $1 in
10
    	case $1 in
Lines 13-32 Link Here
13
    done
19
    done
14
else
20
else
15
	cat
21
	cat
16
fi) | perl -pe '
22
fi) | perl -p -mconstant=CODES,${CODES} -e '
23
($at, $m, $p, $c) = split /:/, CODES;
17
while (s/\t/" " x (8 - ((length($`)-1) % 8))/e) {}
24
while (s/\t/" " x (8 - ((length($`)-1) % 8))/e) {}
18
s/^(\+.*)$/\033[31m$1\033[m/o;
25
s/^(\+.*)$/\033[${p}m$1\033[0m/o;
19
s/^(-.*)$/\033[34m$1\033[m/o
26
s/^(-.*)$/\033[${m}m$1\033[0m/o
20
	if !s/^(--- \d+,\d+ ----.*)$/\033[1m$1\033[m/o;
27
	if !s/^(--- \d+,\d+ ----.*)$/\033[1m$1\033[0m/o;
21
s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/\033[1m$1\033[m/o;
28
s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/\033[1m$1\033[0m/o;
22
s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/\033[1m$1\033[m/o;
29
s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/\033[1m$1\033[0m/o;
23
s/^(!.*)$/\033[35m$1\033[m/o;
30
s/^(!.*)$/\033[${c}m$1\033[0m/o;
24
s/^(@@.*$)/\033[1m$1\033[m/o;
31
s/^(@@.*$)/\033[${at}m$1\033[0m/o;
25
if (/^1.(\d+)(\s+\(\w+\s+\d{2}-\w{3}-\d{2}\):\s)(.*)/) {
32
if (/^1.(\d+)(\s+\(\w+\s+\d{2}-\w{3}-\d{2}\):\s)(.*)/) {
26
	$lastcol = $lastcol || 0;
33
	$lastcol = $lastcol || 0;
27
	$lastcol++ if defined($lastrev) && $lastrev != $1;
34
	$lastcol++ if defined($lastrev) && $lastrev != $1;
28
	$lastrev = $1;
35
	$lastrev = $1;
29
	$lastcol %= 6;
36
	$lastcol %= 6;
30
	$_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[m$3\n";
37
	$_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[0m$3\n";
31
}
38
}
32
' | less -R
39
' | less -R

Return to bug 75310