fd/screencast.sh

55 lines
649 B
Bash
Raw Normal View History

2018-01-20 20:47:29 +01:00
#!/bin/sh
2018-01-26 13:14:38 +01:00
# Designed to be executed via svg-term:
2018-01-26 21:24:49 +01:00
# svg-term --command="sh screencast.sh" --out screencast.svg --padding=10
2018-01-20 20:47:29 +01:00
set -e
2018-01-26 21:24:49 +01:00
set -u
2018-01-20 20:47:29 +01:00
PROMPT="▶"
2018-01-26 12:43:06 +01:00
enter() {
2018-01-26 21:24:49 +01:00
INPUT=$1
DELAY=$2
prompt
2018-01-26 21:24:49 +01:00
sleep $DELAY
type $INPUT
2018-01-26 12:43:06 +01:00
sleep 0.5
2018-01-26 12:50:49 +01:00
printf '%b' " ⏎\n"
2018-01-26 21:24:49 +01:00
eval $INPUT
2018-01-26 12:43:06 +01:00
type "\n"
}
prompt() {
printf $PROMPT
type " "
2018-01-26 12:43:06 +01:00
}
type() {
printf '%b' $1 | pv -qL $[10+(-2 + RANDOM%5)]
2018-01-20 20:47:29 +01:00
}
main() {
IFS='%'
2018-01-26 21:24:49 +01:00
enter "fd" 0
2018-01-26 21:24:49 +01:00
enter "fd -e md" 1
2018-01-20 20:47:29 +01:00
2018-01-26 21:24:49 +01:00
enter "fd -e md --exec wc -l" 1
2018-01-26 12:50:49 +01:00
2018-01-26 21:24:49 +01:00
enter "fd mod" 1
2018-01-26 12:50:49 +01:00
2018-01-26 21:24:49 +01:00
enter "fd sh" 1
2018-01-20 20:47:29 +01:00
2018-01-26 21:24:49 +01:00
enter "fd -H sample" 1
2018-01-20 20:47:29 +01:00
2018-01-26 21:24:49 +01:00
enter "fd -h" 1
prompt
sleep 3
unset IFS
}
2018-01-20 20:47:29 +01:00
main