demo.sh/demo.sh

43 lines
662 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
}
2017-10-08 01:01:25 +00:00
function type()
2017-10-08 01:32:03 +00:00
{ printf "$*" | simtyping; }
function prompt()
{
def="\033[0;00m"
blu="\033[0;34m"
cyn="\033[0;36m"
printf "[$cyn$(whoami)$def@$blu$(hostname)$def $(basename `pwd`)]\$ ";
}
function execute()
{
prompt
type "$@" && wait
printf "\n"
eval "$@"
}
2017-10-08 01:10:27 +00:00
function cmd()
{
prompt
read command
eval "${command}";
}