Skip to content

Instantly share code, notes, and snippets.

@teabot
Last active December 18, 2015 15:29
Show Gist options
  • Save teabot/5804726 to your computer and use it in GitHub Desktop.
Save teabot/5804726 to your computer and use it in GitHub Desktop.
Periodically converts a dot file into a PNG so that I can create diagrams in a text editor and view them in a web browser and/or "OSX Preview".
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage: `basename $0` {dot file}"
exit -1
fi
FILE=$1
NAME=${FILE%.dot}
DOT=$NAME.dot
PNG=$NAME.png
echo "View diagram at URL: file://$PNG"
# Open in Preview on OSX - will auto update whenever it has focus
open -g -a "Preview" $PNG
while :;
do
dot -Tpng -o $PNG $DOT
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment