Skip to content

Instantly share code, notes, and snippets.

@cincauhangus
Created January 12, 2012 09:19
Show Gist options
  • Select an option

  • Save cincauhangus/1599540 to your computer and use it in GitHub Desktop.

Select an option

Save cincauhangus/1599540 to your computer and use it in GitHub Desktop.
Colored Diff
#!/usr/bin/env perl
# a simple modification of the Diff implementation
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
die "usage: cdiff file1 file2\n" unless (@ARGV == 2);
open DIFF, "diff $ARGV[0] $ARGV[1] |" || die ($!);
while (<DIFF>) {
print /^</ ? BOLD RED $_
: /^>/ ? BOLD BLUE $_
: /^-/ ? BOLD GREEN $_
: /^\d/ ? BOLD YELLOW $_
: $_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment