watchexec/doc/watchexec.1.ronn

114 lines
5 KiB
Text
Raw Normal View History

2016-10-29 19:08:55 +02:00
watchexec(1) -- execute commands when watched files change
==========================================================
## SYNOPSIS
watchexec [`--exts` | `-e` <extensions>]... [`--filter` | `-f` <pattern>]... [`--ignore` | `-i` <pattern>]... [`--watch` | `-w` <path>]... [`--restart` | `-r`] [`--clear` | `-c`] [`--postpone` | `-p`] [`--force-poll` <interval>] [`--debounce` | `-d` <interval>] [`--no-vcs-ignore`] [`--no-default-ignore`] [`--verbose` | `-v`] [`--changes-only`] [`--version` | `-V`] [--] <command> [<argument>...]
2016-10-29 19:08:55 +02:00
## DESCRIPTION
2016-11-17 14:46:23 +01:00
Recursively monitors the current directory for changes, executing the command when a filesystem change is detected. By default, watchexec uses efficient kernel-level mechanisms to watch for changes.
2016-10-29 19:08:55 +02:00
At startup, the specified <command> (passing any supplied <argument>s) is run once, and watchexec begins monitoring for changes.
## OPTIONS
2017-02-05 19:29:38 +01:00
* <command>:
Command to run when watched files are modified, and at startup, unless `--postpone` is specified. All <argument>s are passed to <command>. If you pass flags to the command, you should separate it with `--`, for example: `watchexec -w src -- rsync -a src dest`.
2016-10-29 19:08:55 +02:00
* `-e`, `--exts` <extensions>:
2019-10-10 12:39:13 +02:00
Comma-separated list of file extensions to filter by. Leading dots (.rs) are allowed. (This is a shorthand for `-f`).
2016-10-29 19:08:55 +02:00
* `-f`, `--filter` <pattern>:
2017-02-05 19:29:38 +01:00
Ignores modifications from paths that do not match <pattern>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <command>.
2016-10-29 19:08:55 +02:00
2017-03-26 18:25:13 +02:00
* `-s`, `--signal`:
Sends the specified signal (e.g. `SIGKILL`) to the child process. Defaults to `SIGTERM`.
2017-04-06 22:51:52 +02:00
* `-n`, `--no-shell`:
2017-04-06 23:04:57 +02:00
Execute command directly, do not wrap it in `sh -c` resp. `cmd.exe /C`. This is especially useful in combination with `--signal`, as the signal is then send directly to the specified command. While `--no-shell` is a little more performant than the default, it prevents using shell-features like pipes and redirects.
2017-04-06 22:51:52 +02:00
* `--no-meta`:
Ignore metadata changes.
2020-06-23 13:43:55 +02:00
* `--no-environment`:
Do not set WATCHEXEC_*_PATH environment variables for child process.
2017-02-05 19:29:38 +01:00
* `-i`, `--ignore` <pattern>:
2016-10-29 19:08:55 +02:00
Ignores modifications from paths that match <pattern>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.
2017-02-05 19:29:38 +01:00
* `-w`, `--watch` <path>:
Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <command> to be executed.
2016-10-29 19:08:55 +02:00
* `-r`, `--restart`:
2021-04-10 15:06:32 +02:00
Terminates the child process group if it is still running when subsequent file modifications are detected. By default, sends `SIGTERM`; use `--signal` to change that.
2016-10-29 19:08:55 +02:00
* `-c`, `--clear`:
Clears the screen before executing <command>.
* `-p`, `--postpone`:
Postpone execution of <command> until the first file modification is detected.
* `--force-poll` <interval>:
2016-11-17 14:46:23 +01:00
Poll for changes every <interval> ms instead of using system-specific notification mechanisms (such as inotify). This is useful when you are monitoring NFS shares.
2016-10-29 19:08:55 +02:00
* `-d`, `--debounce`:
Set the timeout between detected change and command execution, to avoid restarting too frequently when there are many events; defaults to 500ms.
2016-10-29 19:08:55 +02:00
* `--no-vcs-ignore`:
Skip loading of version control system (VCS) ignore files. By default, watchexec loads .gitignore files in the current directory (or parent directories) and uses them to populate the ignore list.
2017-04-26 03:15:40 +02:00
* `--no-default-ignore`:
Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example `*.swp`, `*.pyc`, and `.DS_Store`.
2017-04-26 03:15:40 +02:00
* `-v`, `--verbose`:
Prints diagnostic messages to STDERR.
* `--changes-only`:
Prints the paths that have changed as diagnostics to STDERR, but not everything else that `--verbose` prints.
* `-V`, `--version`:
Print the version of watchexec.
* `-h`, `--help`:
Print a help message.
2016-10-29 19:08:55 +02:00
## ENVIRONMENT
Processes started by watchexec have environment variables set describing the modification(s) observed. Which variable is set depends on how many modifications were observed and/or what type they were.
If a single file changed (depending on the event type):
* `$WATCHEXEC_CREATED_PATH`, the path of the file that was created
* `$WATCHEXEC_REMOVED_PATH`, the path of the file that was removed
* `$WATCHEXEC_RENAMED_PATH`, the path of the file that was renamed
* `$WATCHEXEC_WRITTEN_PATH`, the path of the file that was modified
* `$WATCHEXEC_META_CHANGED_PATH`, the path of the file whose metadata changed
If multiple files changed:
* `$WATCHEXEC_COMMON_PATH`, the longest common path of all of the files that triggered a change
2016-10-29 19:08:55 +02:00
## EXAMPLES
Rebuild a project when source files change:
$ watchexec make
Watch all HTML, CSS, and JavaScript files for changes:
$ watchexec -e html,css,js make
Run tests when source files change, clearing the screen each time:
$ watchexec -c make test
2017-02-05 19:29:38 +01:00
Launch and restart a node.js server:
2016-10-29 19:08:55 +02:00
$ watchexec -r node app.js
2017-02-05 19:29:38 +01:00
Watch lib and src directories for changes, rebuilding each time:
$ watchexec -w lib -w src make