-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathdice
executable file
·34 lines (28 loc) · 1016 Bytes
/
dice
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
#!/bin/bash
######################################################################
# Dice thingy...
######################################################################
pip=o
p0=" "
p1=" $pip "
p2=" $pip "
p3=" $pip "
p4=" $pip $pip "
p5=" $pip $pip $pip "
cs=$(ansi --save-cursor) ## save cursor position
cr=$(ansi --restore-cursor) ## restore cursor position
dn=$(ansi --down=1) ## move down 1 line
b=$(ansi --bold) ## set bold attribute
dice=(
"$b$cs$p0$cr$dn$cs$p0$cr$dn$cs$p2$cr$dn$cs$p0$cr$dn$p0"
"$b$cs$p0$cr$dn$cs$p1$cr$dn$cs$p0$cr$dn$cs$p3$cr$dn$p0"
"$b$cs$p0$cr$dn$cs$p1$cr$dn$cs$p2$cr$dn$cs$p3$cr$dn$p0"
"$b$cs$p0$cr$dn$cs$p4$cr$dn$cs$p0$cr$dn$cs$p4$cr$dn$p0"
"$b$cs$p0$cr$dn$cs$p4$cr$dn$cs$p2$cr$dn$cs$p4$cr$dn$p0"
"$b$cs$p0$cr$dn$cs$p5$cr$dn$cs$p0$cr$dn$cs$p5$cr$dn$p0"
)
clear
ansi -n --bell
ansi --position=2,5 -n --bg-white --black "${dice[RANDOM%6]}"
ansi --position=2,20 -n --bg-black --white "${dice[RANDOM%6]}"
echo