summaryrefslogtreecommitdiff
path: root/showdot
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-04-27 16:32:20 +0200
committerxengineering <me@xengineering.eu>2022-04-27 16:32:20 +0200
commit982e24828f2e3a52343a120b0381c83686e9940b (patch)
tree86fb499f7738a0fac41bfea95eb537232497d91d /showdot
parentb245db68a0f0325aadec553754db7ae84ca5486f (diff)
downloadscripts-982e24828f2e3a52343a120b0381c83686e9940b.tar
scripts-982e24828f2e3a52343a120b0381c83686e9940b.tar.zst
scripts-982e24828f2e3a52343a120b0381c83686e9940b.zip
Implement showdot
Diffstat (limited to 'showdot')
-rwxr-xr-xshowdot27
1 files changed, 27 insertions, 0 deletions
diff --git a/showdot b/showdot
new file mode 100755
index 0000000..89ada27
--- /dev/null
+++ b/showdot
@@ -0,0 +1,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}"