Hi Everyone,
In my quest for efficiency, I found that I was spending way too much time switching from Emacs to Chrome and then refreshing the browser tab which displays my HTML output. I realized that I needed to have my computer do this work for me. After much Googling I decided to use a utility called fswatch, which as the name implies, watches the filesystem for changes to files. The following instructions are for Mac users, but since fswatch is cross-platform, I imagine the following can be adapted to Linux as well. (Probably just need to change the code in between "do" and "done" in the Bash script below as it is specific to Mac OS X.)
1. Install fswatch. I use homebrew which is the de-facto package manager for Mac. (See
http://brew.sh) Obviously you will need to install homebrew if you do not already have it on your system.
$ brew install fswatch
2. Save the following Bash script under the name "reload" in the same directory where you keep your source XML files:
#!/bin/bash
fswatch -o ../out/html/*.html | while read num
do
osascript -e 'tell application "Google Chrome" to reload active tab of window 1'
osascript -e 'say "Page reloaded master" using "Zarvox"'
done
3. Make the "reload" script you just created executable by typing the following in a terminal:
$ chmod a+x reload
4. Change the path: "../out/html*.html" in the script above to the path that gets you from your src directory to your HTML output directory. Be sure to save your changes to the "reload" script.
5. In a terminal, cd to your src directory where you saved the "reload" script and type:
$ ./reload
At this point, every time you use make to build your HTML files, the browser tab displaying the HTML file should automatically get refreshed. Actually the script will reload the currently active tab, but as long as your project is the currently active tab in Google Chrome, it will get reloaded.
Cheers,
Jason