开发者

Run Script on File Change on Mac OS X

Anyone know about a program for Mac 开发者_开发技巧OS that you can pass the name to an executable and a file to watch, so that it then runs the executable everytime the file being watched changed?

I have something like this in mind:

$ fwatch /Users/foo/doc.tex /Users/foo/run-pdflatex.sh &
  fwatch running. Listening for changes in /Users/foo/doc.tex.
$ echo "This aint no LaTeX" > doc.tex
$ fwatch: Change in /Users/foo/doc.tex detected. Running /Users/foo/run-pdflatex.sh...


I've found fswatch which claims to be "a cross-platform file change monitor", and seems to support all the proper platform solutions like Filesystem Events on macOS.

# Monitor all files in a directory, execute script once when something changes
fswatch -o -r path/to/directory | xargs -n1 -I{} your-command-here
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜