A program to restart, for example, "make" when changing files?

Is there a program that will be automatically restarted, for example, make , when the files are changed?

For example, when I write sphinx documentation, it would be nice if make html started automatically every time I edit any relevant files.

+4
source share
7 answers

For simple things, restarting can be good: http://pypi.python.org/pypi/rerun

"Python script command line executable to re-run this command every time files are changed in the current directory or its subdirectories."

This requires a Python interpreter, but still, if your command or files are written in Python.

 Usage rerun [--help|-h] [--verbose|-v] [--ignore|-i=<file>] [--version] <command> Where: <command> Command to execute --help|-h Show this help message and exit. --ignore|-i=<file> File or directory to ignore. Any directories of the given name (and their subdirs) are excluded from the search for changed files. Any modification to files of the given name are ignored. The given value is compared to basenames, so for example, "--ignore=def" will skip the contents of directory "./abc/def/" and will ignore file "./ghi/def". Can be specified multiple times. --verbose|-v Display the names of changed files before the command output. --version Show version number and exit. 
+8
source

Well, since make won't do anything if nothing has changed, how about

 while true; do sleep 60; make html; done 

or the equivalent in your shell of choice? I don’t think that regular file system layers are event driven in such a way that you will notify you of file changes without doing some of the same yourself, but maybe DBUS can do such things.

+3
source
+2
source

As the answer fooobar.com/questions/32120 / ... watchman seems to work very well:

  $ watchman-make -p '*.c' 'Makefile' -t all 

Re-runs make all every time a *.c or Makefile changed.

It can be installed using

 $ brew install watchman 
+1
source

On Linux, you can use this command line:

 while true; do inotifywait -e close_write *.py; make; done 

Uses the standard inotifywait system command, if it is not available, install with something like:

 sudo apt install inotify-tools 
+1
source

This question was also asked here: https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes/

You can try reflex

 # Rerun make whenever a .c file changes reflex -r '\.c$' make 
0
source

All Articles