Files
tldr/pages.zh/common/entr.md

32 lines
941 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# entr
> 当文件发生更改时运行任意命令。
> 更多信息:<https://eradman.com/entrproject/>.
- 如果任何子目录中的文件发生更改,则使用 `make` 重新构建:
`{{ag -l}} | entr {{make}}`
- 如果当前目录中的任何 `.c` 源文件发生更改,则使用 `make` 重新构建并测试:
`{{ls *.c}} | entr {{'make && make test'}}`
- 在执行 `ruby main.rb` 之前,向任何之前生成的 Ruby 子进程发送 `SIGTERM`
`{{ls *.rb}} | entr -r {{ruby main.rb}}`
- 使用更改的文件 (`/_`) 作为参数运行命令:
`{{ls *.sql}} | entr {{psql -f}} /_`
- [c]lear 屏幕并在 SQL 脚本更新后运行查询:
`{{echo my.sql}} | entr -cp {{psql -f}} /_`
- 如果源文件发生更改,则重新构建项目,输出限制为前几行:
`{{find src/}} | entr -s {{'make | sed 10q'}}`
- 启动并自动 [r]eload 一个 Node.js 服务器:
`{{ls *.js}} | entr -r {{node app.js}}`