::  Posts  ::  RSS  ::  ◂◂RSS  ::  Contact

Introducing icdiff

March 11th, 2009
icdiff, tech  [html]
The first time I used wikipedia to look at revisions I was quite impressed by the colored two column output indicating which bits had changed. Working mostly on the command line, it's been frustrating that diff can't do better than two column output. Even colored diff and cdiff only color lines by whether they're from the left or the right, not whether they're internally different. Python's difflib can create the wikipedia-style two column colored output, though, and with a bit of modification can print to the console with ansi escape sequences:
jefftk@host ~ $ python icdiff.py text_A text_B
This is an unchanged line This is an unchanged line
This is a line with a speleing error This is a line with a spelling error
This line was deleted
Whitespace     shows up where critical Whitespace shows up where critical
But it's not     shown when not But it's not ugly when not
And here I go, adding a line
And the usage:
  usage: icdiff.py [options] left_file right_file

  options:
    -h, --help           show this help message and exit
    --cols=COLS          specify the width of the screen. Autodetection is Linux
                         only
    --context            print only differences with some context
    --numlines=NUMLINES  how many lines of context to print; only meaningful
                         with --context
    --line-numbers       generate output with line numbers
    --show-all-spaces    color all non-matching whitespace instead of just
                         whitespace that is critical for understanding
    --print-headers      label the left and right sides with their file names
  
Improved Color diff: icdiff

Comment via: google plus, facebook

Recent posts on blogs I like:

Transfers from Infrequent to Frequent Vehicles

Imagine yourself taking a train somewhere, and imagine the train is big and infrequent. Let’s say it’s the commuter train from New York down the Northeast Corridor to Newark Airport, or perhaps a low-cost OuiGo TGV from Lyon to Paris. Now imagine that you…

via Pedestrian Observations January 20, 2020

Veganism and restrictive eating

I’m reading the book Intuitive Eating, which I highly recommend. I was looking for something like it that could get me back to trusting my biological hunger without worrying that I need to control myself or my weight. It’s raised my consciousness to the w…

via Holly Elmore January 17, 2020

Algorithms interviews: theory vs. practice

When I ask people at trendy big tech companies why algorithms quizzes are mandatory, the most common answer I get is something like "we have so much scale, we can't afford to have someone accidentally write an O(n^2) algorithm and bring the site d…

via Posts on Dan Luu January 5, 2020

more     (via openring)

More Posts:


  ::  Posts  ::  RSS  ::  ◂◂RSS  ::  Contact