Quick Linux Tip #116:
Question: How do I auto-rebuild my project when source files change?
Try: while inotifywait -r -e modify,create,delete ./src/; do make build; done
Info: inotifywait exits after a single file event, allowing a simple while loop to trigger builds on modification without external watchers.
Examples:
- $
while inotifywait -e modify ./style.css; do sass compile; done# Recompile CSS on change - $
ls ./src/*.go | entr make build# Alternative using the lightweight 'entr' tool - $
fswatch -o ./src | xargs -n1 -I{} make build# Cross-platform alternative file watcher
Note: Install via sudo apt install inotify-tools. Avoid recursive (-r) monitoring on massive directory trees to prevent performance lag; target specific paths instead.
Leave a Reply