Last active
July 31, 2021 01:25
-
-
Save stevegt/d54d7e0875241f4c0f4a42ef6dbe3c05 to your computer and use it in GitHub Desktop.
graphviz xdot and gist driver
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 -ex | |
# usage: graphviz-gist {filename} [optional description goes here] | |
# gist-paste is from the ubuntu 'gist' package | |
github_user=stevegt # XXX | |
id="$1" | |
shift | |
file="$1" | |
shift | |
desc="$@" | |
touch $file | |
idfn=/tmp/$RANDOM | |
( | |
while true | |
do | |
inotifywait -e modify $file | |
sleep 1 | |
kill $xdot || true | |
xdot $file & | |
xdot=$! | |
if [ -z "$id" ] | |
then | |
gist_url=$(gist-paste --skip-empty -f $file -d "$desc" < $file) | |
id=$(echo ${gist_url/*\/}) | |
else | |
gist_url=$(gist-paste -u $id --skip-empty -f $file -d "$desc" < $file) | |
fi | |
echo $id > $idfn | |
done | |
) >> /tmp/graphviz-gist.log 2>&1 & | |
loop=$! | |
vi $file | |
kill $loop | |
id=$(cat $idfn) | |
set +x | |
echo viewer URL: | |
echo https://stevegt.github.io/GraphvizOnline/?url=https://gist.githubusercontent.com/$github_user/$id/raw/$file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment