Lets say you have a bunch of source code files in a project. Whenever you change them, you want some HTML to be generated. After that you go to browser to see how the change looks now. Here is the workflow:
- Step 1: Change file(s)
- Step 2: Run a build script to generate HTML
- Step 3: Open / Reload the page in browser
Well we can automate all the three steps into one using a couple of tools and some scripting magic. We will need a inotify-tools
, NetCat nc
tool and MozRepl.
Install inotify tools and netcat:
sudo yum install -y inotify-tools nc6
Install MozRepl as described here: Refresh Firefox page from Emacs
Make sure that you have started MozRepl by restarting Firefox. Then Alt+T
then Select MozRepl
then Start
.
Now create a simple script to watch for changes like so:
while inotifywait -r -e modify src/
do
# put your command here to generate the html from modified files
make
# now refresh the browser
echo "BrowserReload();" | nc localhost 4242 > /dev/null
end
Keep this script running while you make changes to the source code. You can also automate this with other build tools ( such as Maven, SBT etc. ) and editors ( such as Emacs )