demo.sh/demo.sh

27 lines
418 B
Bash
Raw Normal View History

#!/usr/bin/env bash
TYPE_SPEED="${TYPE_SPEED:-15}"
2017-10-08 00:57:44 +00:00
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
function simtyping()
{ pv -qL $(($TYPE_SPEED+$((-2 + RANDOM%5)))); }
2017-10-08 00:57:44 +00:00
function wait()
{
if [ "$PROMPT_TIMEOUT" == "-1" ]; then
read -rs
else
read -rst "$PROMPT_TIMEOUT"
fi
printf "\n"
2017-10-08 00:57:44 +00:00
}
2017-10-08 01:01:25 +00:00
function type()
{
printf "$*\n" | simtyping
wait
}
function execute()
{ type "$@" && eval "$@"; }