makefilewatch

Is there a smarter alternative to "watch make"?


I ran into this useful tip that if you're working on files a lot and you want them to build automatically you run:

watch make

And it re-runs make every couple seconds and things get built.

However ... it seems to swallow all the output all the time. I think it could be smarter - perhaps show a stream of output but suppress Nothing to be done for 'all' so that if nothing is built the output doesn't scroll.

A few shell script approaches come to mind using a loop and grep ... but perhaps something more elegant is out there? Has anyone seen something?


Solution

  • This one-liner should do it:

    while true; do make --silent; sleep 1; done
    

    It'll run make once every second, and it will only print output when it actually does something.