watchexec
File watcher that runs commands when files change, with .gitignore support and cross-platform filesystem monitoring
watchexec is a file monitoring tool that executes commands when filesystem changes are detected. It monitors the current directory and subdirectories for modifications, then triggers specified commands automatically. The tool handles common development workflows like running unit tests, linters, or build processes when source files change.
The tool coalesces multiple filesystem events into single command executions, which prevents redundant runs when editors create temporary files during saves. It respects .gitignore and .ignore files for filtering watched paths, and uses process groups to manage forking programs. Changed file paths are provided to executed commands through environment variables or STDIN.
watchexec runs on macOS, Linux, and Windows without requiring language runtimes or ecosystem-specific dependencies. It supports file extension filtering, command restarting with the -r flag, and integrates with tools like checkexec for conditional execution and systemfd for development socket-passing. The tool serves developers working across different languages and build systems who need automated command execution based on file changes.
Installation
# via Cargo
cargo install --locked watchexec-cli
# via Binstall
cargo binstall watchexec-cli
Alternatives & related tools
sd
Find and replace CLI tool with regex support, string-literal mode, and faster performance than sed
zizmor
Static analysis tool that finds and fixes security issues in CI/CD configurations, including GitHub Actions workflows, Dependabot, and pre-commit.
tealdeer
Fast Rust implementation of tldr providing simplified, example-based manual pages for command-line tools
tailspin
Log file highlighter (binary: tspin) that colors dates, numbers, IPs, UUIDs, URLs and more in any log format, with no config, and pages output through less.
pastel
Command-line tool to generate, analyze, convert and manipulate colors across multiple formats and color spaces
add a badge to your README
Maintain watchexec? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/watchexec?utm_source=badge)<a href="https://www.trmn.sh/tools/watchexec?utm_source=badge"><img src="https://www.trmn.sh/badge/watchexec.svg" alt="Featured on trmn" height="20"></a>