1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-09 19:05:24 +02:00
tldr/pages/common/watchexec.md

25 lines
940 B
Markdown
Raw Normal View History

2020-05-27 19:47:48 +00:00
# watchexec
> Run arbitrary commands when files change.
> More information: <https://manned.org/watchexec>.
2020-05-27 19:47:48 +00:00
- Call `ls -la` when any file in the current directory changes:
2023-08-23 08:55:18 +02:00
`watchexec {{ls -la}}`
2020-05-27 19:47:48 +00:00
2023-08-23 08:55:18 +02:00
- Run `make` when any JavaScript, CSS and HTML file in the current directory changes:
2020-05-27 19:47:48 +00:00
`watchexec {{[-e|--exts]}} {{js,css,html}} make`
2020-05-27 19:47:48 +00:00
2023-08-23 08:55:18 +02:00
- Run `make` when any file in the `lib` or `src` directory changes:
2020-05-27 19:47:48 +00:00
`watchexec {{[-w|--watch]}} {{lib}} {{[-w|--watch]}} {{src}} {{make}}`
2020-05-27 19:47:48 +00:00
2023-08-23 08:55:18 +02:00
- Call/restart `my_server` when any file in the current directory changes, sending `SIGKILL` to stop the child process:
2020-05-27 19:47:48 +00:00
`watchexec {{[-r|--restart]}} --stop-signal {{SIGKILL}} {{my_server}}`
2025-05-09 18:46:02 +01:00
- Restart the execution of a command when any Java source file in the current directory changes, sending `SIGKILL` and only checking for updates every `n`ms:
`watchexec {{[-r|--restart]}} --stop-signal {{SIGKILL}} --poll {{10000}} {{[-e|--exts]}} {{java}} {{command}}`