colordiffã®æååä½çccdiffãä½ã£ãid:yappo++
diffã«è²ä»ããããã£ããã©ãcolordiffã¿ãããªè¡åä½ãããªãã¦ãæååä½ã§è²ä»ããããã
id:yappoã®String::Diff - Simple diff to String - metacpan.org使ã£ã¦ccdiff(charactor color diff)ã¨ããã®ãã§ã£ã¡ãããã
ã£ã¦ãå¾ããåèªåä½ã®æ¹ãããããªã¨æã£ãã
ã§wdiffã¨colordiffã®çµã¿åããã¨ã試ãã¦ã¿ããã©ã
% cat foo.patch | wdiff -d | colordiff
ã ã¨ãæ¥æ¬èªã®æ±ããããããã¦ä½ãåºåãå¾®å¦ã§â¦ã
Text::WordDiff - Track changes between documents - metacpan.orgã軽ã試ãããã©ãè¡åä½ã§åèªåä½ï¼èª¬æé£ããâ¦ï¼ããã§ããªãã£ã½ãã¦ãããã
String::Diffããæé©ãªã¢ã¸ã¥ã¼ã«ãããããããããã©æ¢ãã®ããã©ãã®ã§ã¨ãããããã®ã¾ã¾ã§ã
ä½¿ãæ¹
以ä¸ã®ãã¼ã¿ããããã¨ãã
% cat foo.old abc % cat foo.new azc % cat foo.patch --- foo.old 2010-11-04 12:27:27.040992700 +0900 +++ foo.new 2010-11-04 12:27:33.149776700 +0900 @@ -1 +1 @@ -abc +azc
1. unifiedå½¢å¼ã®ããããæ¸¡ã
% diff -u foo.old foo.new | ccdiff
% cat foo.patch | ccdiff
% cat - | ccdiff
ãããè²¼ãä»ã
^D
svn diffã§ãããã
2. ã¾ãã¯diffã¨åãããã«ãã¡ã¤ã«ï¼ããã³diffã®ãªãã·ã§ã³ãå¯ï¼ã渡ãï¼å é¨ã§diffãå¼ãã§ãï¼
% ccdiff foo.old foo.new
åºåã¯ã©ããåãã§ä»¥ä¸ã®ããã«ãªãã
--- foo.old 2010-11-04 12:27:27.040992700 +0900 +++ foo.new 2010-11-04 12:27:33.149776700 +0900 @@ -1 +1 @@ -abc +azc
ç¾å¨ã®ã¨ããunifiedå½¢å¼ããåãä»ãã¾ããã
#! perl # # $Id: ccdiff 1008 2010-11-04 10:16:41Z hyoshida $ # eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; use strict; use warnings; use version; our $VERSION = qv('0.0.1'); use autodie; use IO::Pipe; use String::Diff qw(diff); use Term::ANSIColor; %String::Diff::DEFAULT_MARKS = ( remove_open => ( color 'red' ), remove_close => ( color 'reset' ), append_open => ( color 'green' ), append_close => ( color 'reset' ), separator => q{}, ); if ( 2 <= @ARGV ) { # TODO: deal with existing STDIN open STDIN, q{<&=}, IO::Pipe->new->reader( 'diff', '-u', @ARGV ); undef @ARGV; } my @s = (q{}) x 2; foreach (<>) { /^[-]/msx ? ( $s[0] .= $_ ) : /^[+]/msx ? ( $s[1] .= $_ ) : do { print diff(@s), $_; @s = (q{}) x 2; }; } print diff(@s); __END__ =head1 NAME ccdiff - a tool to colorize by the character diff output =head1 USAGE $ ccdiff foo.old foo.new $ diff -u foo.old foo.new | ccdiff $ cat foo.patch | ccdiff =head1 DESCRIPTION a tool to colorize by the character diff output =head1 REQUIRED ARGUMENTS None. =head1 OPTIONS None. =head1 DIAGNOSTICS None. =head1 EXIT STATUS None. =head1 CONFIGURATION ccdiff requires no configuration files. =head1 DEPENDENCIES L<String::Diff|String::Diff> =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS No bugs have been reported. =over =item TODO: add copied context support =item TODO: add ~/.colordiffrc support =item TODO: add multibyte support =back =head1 AUTHOR Hironori Yoshida <yoshida@cpan.org> =head1 LICENSE AND COPYRIGHT This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<perlartistic|perlartistic>. =cut
- STDINã®å¦çã®è¾ºãèªä¿¡ãç¡ããcloseããªãã¨ãããªãã®ãã¨ã<&=ã¨ãã
- æåwhileã§é次å¦çãã¦ããã©ãããã ã¨cat - | ccdiffã®æã«éä¸åºåããã¦ãã¾ã£ã¦é½åãæªãã®ã§foreachã«ç½®ãæããã