-
Notifications
You must be signed in to change notification settings - Fork 0
/
idot
executable file
·57 lines (50 loc) · 1.08 KB
/
idot
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# stolen in part from https://twitter.com/thingskatedid/status/1316074032379248640
set -euo pipefail
if [ -t 0 ]; then
has_stdin=f
else
has_stdin=t
fi
FG=ghostwhite
BG=transparent
# Look for command line flags.
while [ $# -gt 0 ]; do
case "$1" in
*)
if [ -r "$1" ]; then
has_stdin=f
dot \
-Gbgcolor=$BG \
-Gcolor=$BG \
-Gbackground=$BG \
-Ncolor=$FG \
-Ecolor=$FG \
-Efontcolor=$FG \
-Nfontcolor=$FG \
-Tsvg "$1" | \
rsvg-convert -z 3 | \
imgcat
else
error "idot: $1: No such file or directory"
exit 2
fi
;;
esac
shift
done
# Read and print stdin
if [ $has_stdin = t ]; then
dot \
-Gbgcolor=$BG \
-Gcolor=$BG \
-Gbackground=$BG \
-Ncolor=$FG \
-Ecolor=$FG \
-Efontcolor=$FG \
-Nfontcolor=$FG \
-Tsvg | \
rsvg-convert -z 3 | \
imgcat
fi
exit 0