diffcolor (DiffColor.py)

Winston C. Yang

winston at cs dot wisc dot edu

This file was last modified on 2010-01-15.

 

Download diffcolor

 

diffcolor’s license is the GNU General Public License version 3, or any later version.

 

diffcolor colors and line-wraps the output of Python's difflib module. (Python is a programming language.) A screenshot:

 

 

 

 

 

The screenshot shows the differences between two files.

 

 

SYSTEM REQUIREMENTS

 

 

EXAMPLE USAGE

 

You can create an alias “diffcolor” for “python3 DiffColor.py”. See a later section for how to create an alias.

 

Example: (No alias) Find the differences between two files called file1 and file2. You might have to specify paths to python3, DiffColor.py, file1, or file2.

 

        python3 DiffColor.py file1 file2

 

Example. The previous example with an alias.

 

        diffcolor file1 file2

 

Example. Show more text per line. If the output looks unusual, widen your window.

 

        diffcolor --columns=150 file1 file2

 

Example. Make each tab be 4 spaces. Note that tabs are underlined in the output.

 

        diffcolor --tab=4 file1 file2

 

Example. Show help.

 

        diffcolor --help

 

CREATE AN ALIAS FOR DIFFCOLOR

 

Instead of typing

 

        python3 DiffColor.py

 

you can create an alias “diffcolor” as follows.

 

Type

 

        echo $0

 

If the output is "-bash", you are using the Bourne-Again Shell.

 

If the output is "-tcsh", you are using the TENEX (operating system) C Shell.

 

If your shell is different, you might have to change the following directions.

 

If you are using bash, add the following line to the bash resource configuration file .bashrc, which may be in your home directory. Type cd or cd ~/ to go to your home directory. You may have to specify paths to python3 or DiffColor.py.

 

        alias diffcolor="python3 DiffColor.py"

 

If you are using tcsh, add the following line to your .cshrc.local file or a similar file:

 

        alias diffcolor "python3 DiffColor.py"

 

Save the .bashrc file, or .cshrc.local, or similar file.

 

Exit your text editor.

 

On the command line, in your home directory, type

 

        source .bashrc

 

or

 

        source .cshrc.local