Say you want to edit
file.md in your favorite text editor but want to see a preview of the resulting HTML in Safari. On Mac OS X. Get yourself a new bash shell and run the following commands:
brew install multimarkdown brew install fswatch echo '#!/bin/bash multimarkdown --full "file.md" > \ /tmp/file.html && \ open -g /tmp/file.html' > /tmp/rebuild.sh \ && chmod +x /tmp/rebuild.sh; \ fswatch -o "file.md" | xargs -n1 /tmp/rebuild.sh
Now every time you save
fswatch will run the rebuild script, passing the file through multimarkdown and handing the resulting HTML file to the
open command. The
-g flag in
open keeps Safari from jumping to the foreground every time the script runs.
Safari has the nice feature that if you click on a link to
http://example.com is already loaded in some tab, it will switch to that tab and reload the page. Not sure if Chrome does the same, but there's probably a setting or extension for that.
Note that there's a newline after the first line in the string we're passing to
Who needs a dedicated live previewing markdown editor, anyway?