TL;DR — Quick Summary
Watchexec watches for file changes and reruns commands automatically. Better than nodemon for any language — supports debouncing, filtering, and signals.
Watchexec is the universal file watcher. Change a file, it runs your command — any language, any tool. No configuration files, no plugins, just watchexec 'your command'.
Installation
# macOS
brew install watchexec
# Arch Linux
sudo pacman -S watchexec
# Cargo
cargo install watchexec-cli
# Ubuntu (via cargo or binary release)
cargo install watchexec-cli
Usage
# Watch everything, run on change
watchexec 'cargo test'
watchexec 'make build'
watchexec 'python main.py'
# Filter by extension
watchexec -e rs,toml 'cargo build'
watchexec -e py 'pytest'
watchexec -e ts,tsx 'npm test'
watchexec -e go 'go test ./...'
# Restart mode (kill and rerun — for servers)
watchexec -r 'npm start'
watchexec -r 'python app.py'
watchexec -r 'go run main.go'
# Ignore patterns
watchexec -i '*.log' -i 'node_modules' 'npm test'
watchexec -i 'target/' 'cargo build'
# Watch specific directory
watchexec -w src/ -w tests/ 'cargo test'
# Debounce (wait 500ms after last change)
watchexec --debounce 500 'make build'
# Clear screen before each run
watchexec -c 'cargo test'
# Shell mode (needed for pipes/redirects)
watchexec --shell=bash 'cargo test 2>&1 | head -20'
Comparison
| Feature | Watchexec | nodemon | entr | inotifywait |
|---|---|---|---|---|
| Language | Any | Node.js | Any | Any |
| .gitignore | Yes | No | No | No |
| Restart mode | Yes | Yes | No | No |
| Debounce | Yes | Yes | No | No |
| Filter | ext/pattern | ext | manual | manual |
| Speed | Fast (Rust) | Moderate | Fast | Fast |
Summary
- Watchexec runs any command when files change — language-agnostic nodemon
- Filter by extension, ignore patterns, respects .gitignore
- Restart mode (-r) for servers: kills and restarts on change
- Debouncing, screen clearing, signal handling built-in
- Written in Rust for fast file system watching