demo.sh/demo.sh

27 lines
467 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()
2017-10-08 01:32:03 +00:00
{ printf "$*" | simtyping; }
function execute()
{ type "$@" && wait && eval "$@"; }
2017-10-08 01:10:27 +00:00
function cmd()
{ read command && eval "${command}"; }