summaryrefslogtreecommitdiff
path: root/showdot.sh
blob: 89ada278df0758b5905e0ef63db42214274e25a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh


# usage: ./showdot source.dot [compilation args]


# process arguments
code=$1
shift

file=$(mktemp)

# compile *.dot code to *.png
if ! dot "$@" -T png -o "${file}" "${code}"
then
	echo "Failed to compile with GraphViz."
	exit 1
fi

# launch image viewer
if ! sxiv "${file}"
then
	echo "Failed to display generated image with sxiv."
	exit 1
fi

rm "${file}"