TL;DR — Quick Summary
watchexec runs commands when files change. Watch specific patterns, debounce events, restart long-running processes — automatic re-builds, re-tests, re-runs on save.
watchexec re-runs on save. Tests, builds, servers — automatic on every file change.
Installation
# macOS
brew install watchexec
# Cargo
cargo install watchexec-cli
Usage
# Re-run tests on file changes
watchexec -- cargo test
# Filter by extension
watchexec --exts rs,toml -- cargo build
# Restart server on changes
watchexec --restart -- ./run-server.sh
# Watch specific directory
watchexec --watch src/ -- npm run build
# Custom debounce
watchexec --debounce 1000 -- make lint
Summary
- watchexec runs commands when files change
- Built-in debouncing and signal handling
- Filter by extension, path, or ignore patterns
- Restart long-running processes with —restart
- Written in Rust — cross-platform, fast