"open or reload" html doc from command line? I have a program which generates some html documentation.  At the end of the script, I use the open command to automatically view the page in the browser.

generate-document &gt; index.html
open index.html


However, after iterating on the code, I end up with numerous obsolete copies of index.html open in my browser.

Is there a way (either from the command line, or within the browser) to say something like "if index.html is already being viewed refresh it, otherwise load it."?

generate-document &gt; index.html
open-or-reload index.html


Safari or Chrome specific methods are fine.
Check out LiveReload. It is an app that watches your HTML files and can automatically for reload the pages in your browser. LiveReload can also do other things like automatically recompile SASS files to CSS and then reload the browser. 

In addition to the app at the link above, LiveReload is available on GitHub under a "Open Community Indie Software License" which is not quite open source, but does include a dead man clause to convert to MIT if no new binary updates come out for two years. https://github.com/livereload/LiveReload