Running
watchexec <cmd> [args]
Run a command whenever files change
watchexec -- <cmd> --flag
Stop option parsing before the command
watchexec -p <cmd>
Postpone: skip the initial run
watchexec -r <cmd>
Restart the command on change
watchexec -c <cmd>
Clear the screen before each run
watchexec -n <cmd>
No shell: run the program directly
watchexec --shell <shell> <cmd>
Choose the shell, e.g. bash or zsh
watchexec -E <KEY=VALUE> <cmd>
Set an env var for the command only
watchexec --workdir <dir> <cmd>
Run the command in another directory
watchexec -I <cmd>
Interactive: r restart, s stop, p pause, q quit
watchexec --exit-on-error <cmd>
Quit when the command fails
watchexec --timeout <time> <cmd>
Stop a run that takes too long
watchexec --delay-run <time> <cmd>
Sleep before each run
watchexec --timings <cmd>
Print how long each run took
watchexec -q <cmd>
Hide watchexec's own start/stop messages
watchexec -N <cmd>
Desktop notification when the run starts or ends
watchexec --bell <cmd>
Ring the terminal bell when done
What to watch
-w <path>
Watch a file or directory (repeatable)
-W <dir>
Watch a directory without recursion
-e <ext,ext>
Only react to these extensions
Give them without dots: -e rs,toml
-f <glob>
Only react to paths matching a pattern
-i <glob>
Ignore paths matching a pattern
--ignore-file <path>
Load ignore patterns from a file
--filter-file <path>
Load filter patterns from a file
-F <file>
Read watch paths from a file (- for stdin)
--no-vcs-ignore
Watch files that .gitignore excludes
--no-default-ignore
Also watch .git, swap files, .DS_Store
--no-discover-ignore
Skip loading every ignore file
--ignore-nothing
Ignore no files, not even defaults
--project-origin <dir>
Override the detected project root
--fs-events <list>
Filter by event: create, remove, rename, modify, access
--no-meta
Skip metadata-only events
-j <expr>
Filter events with a jaq program
Changed paths
--emit-events-to <mode>
none, environment, stdio, file, json-stdio, json-file
--emit-events-to=json-stdio
Send events as JSON lines on stdin
--emit-events-to=environment
Set WATCHEXEC_*_PATH variables (deprecated)
Variables: WATCHEXEC_COMMON_PATH plus _CREATED_, _REMOVED_,
_RENAMED_, _WRITTEN_, _META_CHANGED_ and
_OTHERWISE_CHANGED_PATH
--print-events
Print the events that triggered a run
--only-emit-events
Emit events only; run no command