3 homepage: https://github.com/watchexec/watchexec
5 watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications.
8 ### Updating `watchexec`
10 `webi watchexec@stable`
12 Use the `@beta` tag for pre-releases.
16 `watchexec` runs a given command when any files in watched directories change. \
17 It respects `.[git]ignore`.
19 The full `--help` detailed and very useful. Here's the shortlist of what I find
23 -w, --watch ./src/ watch the given directory
24 -e, --exts js,html,css watch only the given extensions
25 -i, --ignore '*.md' do not watch the given pattern
26 -d, --debounce 5000 the minimum number of milleseconds
27 to wait between changes
29 -r, --restart restart the process (for servers and such)
30 -s, --signal SIGHUP like -r, but with a signal (ex: SIGHUP)
31 -c, --clear clear the screen between command runs
32 -W (wait) ignore all changes while the command runs
34 -- npm start what command to run, which its arguments
36 --no-ignore disregard both .ignore and .gitignore
37 --no-vcs-ignore disregard only .gitignore
38 --no-default-ignore disregard built-in ignore lists
43 Example: List the directory when any files change.
46 watchexec -c -- ls -lah
49 ### Advanced Usage Example
51 Here's a "kitchen sink" example.
54 watchexec -c -r -s SIGKILL -d 2000 -W --verbose \
55 -w ./src -w ./lib -w ./server.js \
56 -e ts,js,sass,css,html \
57 -i '.git' '*.min.js' -i '*.min.css' \
61 ### How to use (Node, Go, Rust, rsync)
63 These examples show how you might use this for builds, servers, and publishing
68 watchexec -W -- npm run build
69 watchexec -r -- npm start
72 watchexec -- go build .
73 watchexec -r -- go run .
76 watchexec -- cargo build --bin
77 watchexec -r -- cargo run --bin
80 watchexec -- rsync -avhP ./ ./srv/MY_PROJECT/
82 # rsync (remote publish)
83 watchexec -- rsync -avhP ./ app@example.com:~/srv/MY_PROJECT/