| Crates.io | watchdiff-tui |
| lib.rs | watchdiff-tui |
| version | 0.2.0 |
| created_at | 2025-07-24 08:40:00.105027+00 |
| updated_at | 2025-07-24 08:40:00.105027+00 |
| description | A high-performance file watcher with beautiful TUI showing real-time diffs |
| homepage | https://github.com/xicv/watchdiff |
| repository | https://github.com/xicv/watchdiff |
| max_upload_size | |
| id | 1765797 |
| size | 218,462 |
A professional-grade file watcher with beautiful TUI, multiple diff algorithms, and comprehensive patch export capabilities, written in Rust.
.gitignore patterns automaticallycargo install watchdiff-tui
git clone git@github.com:xicv/watchdiff.git
cd watchdiff
cargo build --release
./target/release/watchdiff
# Watch current directory with TUI
watchdiff-tui
# Watch specific directory
watchdiff-tui /path/to/project
# Watch with text output
watchdiff-tui --output text
# Watch only specific file types
watchdiff-tui --extensions rs,py,js
# JSON output for scripting
watchdiff-tui --output json
# Use different diff algorithms
watchdiff-tui --algorithm myers # Fast, general purpose (default)
watchdiff-tui --algorithm patience # Better for refactored code
watchdiff-tui --algorithm lcs # Minimal diffs
# Export patches while watching
watchdiff-tui --export-dir ./patches /path/to/project
# Combine algorithm and export
watchdiff-tui --algorithm patience --export-dir ./patches
WatchDiff features a modern, responsive terminal user interface built with ratatui. The interface is designed for maximum productivity and ease of use.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Changes (โโ to scroll, PgUp/PgDn, Home/End) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [12:34:56] MODIFIED src/main.rs โ
โ --- src/main.rs โ
โ +++ src/main.rs โ
โ @@ -15,7 +15,8 @@ โ
โ - fn main() { โ
โ + fn main() -> Result<()> { โ
โ let cli = Cli::parse(); โ
โ + println!("Starting WatchDiff..."); โ
โ โ
โ [12:34:52] CREATED docs/api.md โ
โ Preview: โ
โ # API Documentation โ
โ This document describes the WatchDiff API... โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Watched Files (847) (โโ to scroll) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ src/main.rs โ
โ src/lib.rs โ
โ src/cli.rs โ
โ src/watcher.rs โ
โ src/diff.rs โ
โ src/tui.rs โ
โ ... โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Status โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Press q to quit, h for help, โโ to scroll diff โ
โ Events: 23 | Files watched: 847 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Top Panel - Changes Log (70% height)
๐ Middle Panel - File List (25% height)
โน๏ธ Bottom Panel - Status Bar (5% height)
| Key | Action |
|---|---|
q, Esc |
Quit application |
h, F1 |
Toggle help screen |
โ, k |
Scroll diff log up |
โ, j |
Scroll diff log down |
PgUp |
Scroll diff log up (fast) |
PgDn |
Scroll diff log down (fast) |
Home |
Go to top of diff log |
End |
Go to bottom of diff log |
โ, โ |
Scroll file list |
Press h or F1 to open the interactive help screen:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Help โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ WatchDiff - File Watching Tool โ
โ โ
โ Keyboard Shortcuts: โ
โ โ
โ q, Esc - Quit the application โ
โ h, F1 - Show/hide this help โ
โ โ, k - Scroll diff log up โ
โ โ, j - Scroll diff log down โ
โ PgUp - Scroll diff log up (fast) โ
โ PgDn - Scroll diff log down (fast) โ
โ Home - Go to top of diff log โ
โ End - Go to bottom of diff log โ
โ โ, โ - Scroll file list โ
โ โ
โ Features: โ
โ โ
โ โข Real-time file change monitoring โ
โ โข Respects .gitignore patterns โ
โ โข Shows diffs for text file changes โ
โ โข Scrollable diff log and file list โ
โ โข High performance with async processing โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
For non-interactive use cases, WatchDiff supports several output formats:
--output text)$ watchdiff-tui --output text
Watching: /home/user/project
Press Ctrl+C to quit
---
[12:34:56] MODIFIED src/main.rs
- fn main() {
+ fn main() -> Result<()> {
let cli = Cli::parse();
+ println!("Starting WatchDiff...");
[12:34:52] CREATED docs/README.md
--output json){"path":"src/main.rs","kind":"Modified","timestamp":{"secs_since_epoch":1703932496,"nanos_since_epoch":0},"diff":"--- src/main.rs\n+++ src/main.rs\n@@ -1,3 +1,4 @@\n-fn main() {\n+fn main() -> Result<()> {\n let cli = Cli::parse();\n+ println!(\"Starting WatchDiff...\");","content_preview":null}
--output compact)$ watchdiff-tui --output compact
M src/main.rs
C docs/README.md
D old_file.txt
Format Legend:
C = CreatedM = ModifiedD = DeletedV = MovedOptions:
-m, --mode <MODE> File watching mode [auto|native|polling]
--max-events <N> Maximum events to store [default: 1000]
-v, --verbose Enable verbose logging
--no-color Disable colored output
--extensions <EXTS> File extensions to watch (e.g., rs,py,js)
--ignore <PATTERNS> Additional patterns to ignore
--context <N> Number of diff context lines [default: 3]
--output <FORMAT> Output format [tui|json|text|compact]
--poll-interval <MS> Polling interval in ms [default: 1000]
--algorithm <ALG> Diff algorithm [myers|patience|lcs] [default: myers]
--export-dir <DIR> Export patches to directory (TUI mode only)
WatchDiff supports multiple diff algorithms, each optimized for different scenarios:
| Algorithm | Best For | Characteristics |
|---|---|---|
| Myers | General purpose | Fast, widely used, good balance |
| Patience | Code refactoring | Better handling of moved code blocks |
| LCS | Minimal changes | Produces smallest possible diffs |
When using --export-dir, WatchDiff automatically saves patches in multiple formats:
.patch files) - Standard diff format.git.patch files) - Git-compatible format# Watch Rust project files only
watchdiff-tui --extensions rs,toml,md
# Watch with additional ignores
watchdiff-tui --ignore "*.log,tmp/*"
# JSON output piped to file
watchdiff-tui --output json > changes.log
# Compact format for build scripts
watchdiff-tui --output compact --no-color
# Export patches for review process
watchdiff-tui --algorithm patience --export-dir ./review-patches
WatchDiff can also be used as a Rust library with a powerful API:
use watchdiff_tui::{
diff::{DiffGenerator, DiffAlgorithmType, DiffFormatter},
export::DiffExporter,
};
// Generate diffs with different algorithms
let generator = DiffGenerator::new(DiffAlgorithmType::Patience);
let result = generator.generate(old_content, new_content);
// Format as unified diff
let formatted = DiffFormatter::format_unified(&result, "old.rs", "new.rs");
// Export to file
let exporter = DiffExporter::unified();
exporter.export_diff(&result, old_path, new_path, "changes.patch")?;
// Get statistics
println!("Changes: {} additions, {} deletions",
result.stats.lines_added,
result.stats.lines_removed
);
See examples/advanced_usage.rs for complete usage examples.
WatchDiff is built with modern Rust practices and clean architecture:
src/
โโโ core/ # Core file watching and event handling
โ โโโ events.rs # Event definitions and processing
โ โโโ filter.rs # File filtering with .gitignore support
โ โโโ watcher.rs # File system monitoring
โโโ diff/ # Modular diff generation system
โ โโโ algorithms.rs # Trait-based algorithm implementations
โ โโโ generator.rs # High-level diff generation
โ โโโ formatter.rs # Multiple output formats
โโโ export/ # Professional patch export capabilities
โโโ ui/ # Terminal user interface
โโโ highlight.rs # Syntax highlighting integration
notify crate for cross-platform filesystem eventsratatui with crossterm for beautiful terminal interfacessyntect crate for 25+ programming languagesclap for robust argument parsing with derive macrossimilar crate with multiple algorithm implementationsignore crate for comprehensive .gitignore supporttokio for non-blocking operationschrono for export timestamps and metadataMIT License - see LICENSE file for details.
Contributions welcome! Please open issues or pull requests.