A powerful side-by-side file comparison tool for Windows, inspired by the Linux diff command but with enhanced visual features and separate CLI and GUI interfaces.
- Side-by-side comparison with syntax highlighting
- Separate CLI and GUI commands for specific use cases
- Colored terminal output with Windows support
- Ignore whitespace option
- Statistics showing added, deleted, and changed lines
- Cross-platform Python implementation
- Easy to use with simple command-line interface
- Clone or download this repository
- Install Python dependencies:
pip install -r requirements.txt
Launch the graphical interface:
python src/gdiff.pyOr use the batch file:
gdiff.batLaunch GUI with files pre-selected:
python src/gdiff.py file1.txt file2.txtOr use the batch file:
gdiff.bat file1.txt file2.txtCompare two files:
python src/cdiff.py file1.txt file2.txtOr use the batch file:
cdiff.bat file1.txt file2.txtpython src/cdiff.py [options] file1 file2
Options:
-h, --help Show help message
-w, --ignore-whitespace
Ignore whitespace differences
-c CONTEXT, --context CONTEXT
Number of context lines to show (default: 3)
--no-color Disable colored output
--width WIDTH Output width (default: 120)
-s, --stats Show statisticspython src/gdiff.py [options] [file1] [file2]
Options:
-h, --help Show help message
-w, --ignore-whitespace
Ignore whitespace differences (pre-set in GUI)
file1 First file to compare (optional)
file2 Second file to compare (optional)-
Basic CLI comparison:
cdiff.bat file1.txt file2.txt
-
CLI with ignore whitespace:
cdiff.bat -w file1.txt file2.txt
-
CLI with statistics:
cdiff.bat -s file1.txt file2.txt
-
CLI with custom width:
cdiff.bat --width 100 file1.txt file2.txt
-
Launch GUI:
gdiff.bat
-
Launch GUI with files pre-selected:
gdiff.bat file1.txt file2.txt
- Files are displayed side-by-side for easy comparison
- Line numbers are shown for both files
- Changes are aligned properly for visual clarity
- Red: Deleted lines (only in left file)
- Green: Added lines (only in right file)
- Yellow: Changed lines (different in both files)
- Gray: Unchanged lines
- File browser for easy file selection
- Synchronized scrolling between panes
- Real-time statistics in status bar
- Ignore whitespace checkbox
- Resizable interface with proper scaling
- Colored terminal output (works on Windows)
- Configurable output width
- Context line control
- Statistics display
- Proper exit codes (0 for no differences, 1 for differences, 2 for errors)
- diff_engine.py: Core comparison logic using Python's difflib
- cli.py: Command-line interface with colored output
- gui.py: Tkinter-based graphical interface
- main.py: Unified entry point for both interfaces
- colorama: Windows-compatible colored terminal output
- tkinter: GUI framework (usually included with Python)
- Python 3.7+: Required for type hints and modern features
- Text files: UTF-8 and Latin-1 encoding support
- Any file type: Basic text comparison works with any file
- Large files: Efficient memory usage with line-by-line processing
To use cdiff and gdiff from anywhere on your system:
- Add the diffTool directory to your Windows PATH environment variable
- Or create
.cmdfiles in a directory that's in your PATH:# cdiff.cmd @echo off "C:\path\to\diffTool\cdiff.bat" %* # gdiff.cmd @echo off "C:\path\to\diffTool\gdiff.bat" %*
Then you can use:
cdiff file1.txt file2.txt
gdiff file1.txt file2.txt
gdiffTo create a standalone executable:
-
Install PyInstaller:
pip install pyinstaller
-
Create executable:
pyinstaller --onefile --windowed src/main.py
- Ensure Python is installed and in your PATH
- Try
python3instead ofpythonon some systems
- On Linux:
sudo apt-get install python3-tk - On Windows: Tkinter is usually included with Python
- Ensure colorama is installed:
pip install colorama - Use
--no-colorflag to disable colors
This project is open source and available under the MIT License.
For detailed development information, architecture decisions, and AI-assisted development context, see ai-context.md. This document contains:
- Complete development process and decisions
- Technical implementation details
- Testing results and known issues
- Future enhancement roadmap
- Code quality standards and deployment options
Contributions are welcome! Please feel free to submit pull requests or report issues. Before contributing, please review the ai-context.md file for detailed technical context and development standards.
Based on the development roadmap in ai-context.md:
- Syntax Highlighting: Add pygments integration for code files
- Word-level Differences: Highlight specific changed words within lines
- Directory Comparison: Compare entire directory structures
- Binary File Support: Handle binary files with hex comparison
- Export Functionality: Save results to HTML/PDF
- Configuration Files: User-customizable settings
- Plugin System: Allow custom comparison algorithms
- Performance Optimization: Handle very large files more efficiently
- Integration with VCS: Git/SVN integration
- Network File Support: Compare files over network
- Backup/Restore: Integrated backup functionality
- Themes: Multiple color schemes