I tend to build very often when working; in this post, I describe how I went from a build every few minutes to automatic builds on every file change.
The underlying idea is this: if something is hard to do, you’ll avoid doing it. Point in case, if you have to type
M-x compile RET in order to build, you usually won’t. Since I think you shouldn’t be limited by your tools, I wanted something that would build automatically in the background.
My solution is
permamake.sh, a bash script that uses
inotify to watch a set of files for changes, and calls
make whenever a change occurs. Basically, it calls
inotifywait, followed by
make in a loop:
Over the past few months, this short script has made development much more pleasant for me. So much so, that I now use it for everything from compiling LaTeX, to building Haskell. In fact, if I’m not browsing the web, my screen almost always looks like this now:
Running it is also straightforward; here are some of my recent invocations. Each time, I call
permamake.sh on the source files of each project:
% permamake.sh Main.hs templates/* r/* \ posts/* Makefile % permamake.sh Makefile *.tex % permamake.sh $(find src/ -name '*.java') % permamake.sh $(find . -name '*.xml' \ -o -name '*.scala')
The last time I showed
permamake.sh to somebody, they remarked that it’s like flymake, but worse. Although it’s far less featureful, it does have one advantage over flymake and other similar systems:
permamake.sh will work out of the box with any project that has a
I’d love to hear suggestions for improving
permamake.sh, or about other people’s workflows in the comments.