summaryrefslogtreecommitdiffstats
path: root/mutt-ccze
blob: 3bcc935bcfac6dea51522237c5c6d40ad94a7f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl

use strict;
use warnings;

use Carp::Assert;
use IPC::Run qw(start);

my ($in, $out);

my $colorizer = start [qw(ccze -A -o), 'nolookups,transparent'], \$in, \$out;

while (<STDIN>) {
	my $in_header =   1  .. /^$/;
	my $in_body   = /^$/ .. eof;

	if ($in_header) {
		print $_;
	} else {
		assert($in_body);
		$in .= $_;
	}
}

finish $colorizer;
print $out;