Created
October 8, 2014 16:07
-
-
Save madx/600ab8c1b68ea860260a to your computer and use it in GitHub Desktop.
Quick and dirty markdown live previewer in bash using surf and xdotool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
render() { | |
marked source.md > output.html | |
} | |
cleanup() { | |
if [ -d /proc/$surf_pid/ ]; then | |
kill $surf_pid | |
fi | |
if [ -f .surf_xid ]; then | |
rm .surf_xid | |
fi | |
} | |
render | |
surf -x $(pwd)/output.html > .surf_xid & | |
surf_pid=$! | |
trap cleanup EXIT | |
inotifywait -qm source.md -e CLOSE_WRITE | while read; do | |
render | |
xdotool key --window `cat .surf_xid` ctrl+r | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment