-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-demos.sh
executable file
·62 lines (50 loc) · 1.21 KB
/
show-demos.sh
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
58
59
60
61
62
#!/bin/bash
( which asciinema ) > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "asciinema is not installed!"
exit 1
fi
( which figlet ) > /dev/null 2>&1
[ $? -eq 0 ] && figlet_available=1 || figlet_available=0
set -euo pipefail
if [ "$#" -gt 0 ]; then
x="$1"
start_at=$((x-1))
else
start_at=0
fi
cat <<EOF
Following keyboard shortcuts are available:
Space - toggle pause,
. - step through a recording a frame at a time (when paused),
Ctrl+C - exit.
to stop the demo, keep hitting ctrl+c....
EOF
sleep 3
must_stop=""
function stop_it {
echo "stopping..."
must_stop="yes"
}
trap stop_it SIGINT SIGTERM
while true; do
clear
for demo_file in $(ls *-ascii.cast); do
if [ "$start_at" -gt 0 ]; then
start_at=$(($start_at-1))
continue
fi
demo_name=$(echo $demo_file | sed -E 's/[0-9]+-kv-(.*)-ascii.cast/\1/')
if [ $figlet_available -ne 0 ]; then
width=$(tput cols)
figlet -w "$width" "$demo_name"
echo
else
echo "Next demo: $demo_name..."
echo
fi
sleep 1
asciinema play -i 1 -s 1.5 "$demo_file"
[ -z "$must_stop" ] || exit 0
done
done