watchexec logo

watchexec

File watcher that runs commands when files change, with .gitignore support and cross-platform filesystem monitoring

install

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

add a badge to your README

Maintain watchexec? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/watchexec.svg)](https://www.trmn.sh/tools/watchexec?utm_source=badge)
HTML
<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>