As far as I can tell, this is impossible. Command:
open file:///path/to/file.html
successfully opens the specified HTML file in the default browser, but does not pass the #test binding to this file. However, the same thing works with the http:// URL. My suspicion is that the Apple Events used to process the file:// request indicate only the file name and not the URL, so the anchor cannot be saved.
source share