Advertisement
dyeske

perl color diff

Oct 26th, 2020
2,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.63 KB | None | 0 0
  1. use strict;
  2. use Term::ANSIColor qw(:constants);
  3. use vars qw($AUTORESET $EACHLINE);
  4. my @output;
  5.  
  6. if ( -t STDIN ) {
  7.     my $cla = join( " ", @ARGV );
  8.     @output = `$cla`;
  9. }
  10. else {
  11.     @output = (<STDIN>);
  12. }
  13.  
  14. foreach my $line (@output) {
  15.     $line =~ s/(^Index.*)/RED ON_CYAN $1 . RESET/eg;
  16.     $line =~ s/(^={67}.*)/BOLD CYAN $1 . RESET/eg;
  17.     $line =~ s/(^\@\@ .*)/BOLD BLUE $1 . RESET/eg;
  18.     $line =~ s/(^\-\-\- .*)/REVERSE MAGENTA $1 . RESET/eg;
  19.     $line =~ s/(^\+\+\+ .*)/REVERSE BLUE $1 . RESET/eg;
  20.     $line =~ s/(^\+.*)/BOLD GREEN $1 . RESET/eg;
  21.     $line =~ s/(^\-.*)/BOLD RED $1 . RESET/eg;
  22.     print $line;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement