From f38702e5a52e1350b9349bc297ccd0b50b1941c3 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 5 Sep 2021 02:10:41 +0200 Subject: diff(1): Add --color support Adds a --color flag to diff(1) that supports the same options as GNU's diff(1). The colors are customizable with the env var DIFFCOLORS in a format similar to grep(1)'s GREPCOLORS. An example would be 04;36:41 for additions to be underlined light blue, and deletions have a red background. Differential Revision: https://reviews.freebsd.org/D30545 --- usr.bin/diff/diff.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'usr.bin/diff/diff.h') diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index 7ae700810fc6..5164fe22ace4 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -87,17 +87,25 @@ #define D_SKIPPED2 6 /* path2 was a special file */ #define D_ERROR 7 /* A file access error occurred */ +/* + * Color options + */ +#define COLORFLAG_NEVER 0 +#define COLORFLAG_AUTO 1 +#define COLORFLAG_ALWAYS 2 + struct excludes { char *pattern; struct excludes *next; }; extern bool lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; -extern bool ignore_file_case, suppress_common; +extern bool ignore_file_case, suppress_common, color; extern int diff_format, diff_context, status; extern int tabsize, width; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; extern char *group_format; +extern const char *add_code, *del_code; extern struct stat stb1, stb2; extern struct excludes *excludes_list; extern regex_t ignore_re; -- cgit v1.2.3