refactored prompt drawing to separate function

This commit is contained in:
Kjistóf 2017-10-08 04:22:35 +02:00
parent d1f16360e5
commit 101d4b36b1

12
demo.sh
View File

@ -3,10 +3,6 @@
TYPE_SPEED="${TYPE_SPEED:-15}"
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
def="\033[0;00m"
blu="\033[0;34m"
cyn="\033[0;36m"
function simtyping()
{ pv -qL $(($TYPE_SPEED+$((-2 + RANDOM%5)))); }
@ -23,9 +19,15 @@ function wait()
function type()
{ printf "$*" | simtyping; }
def="\033[0;00m"
blu="\033[0;34m"
cyn="\033[0;36m"
function prompt()
{ printf "[$cyn$(whoami)$def@$blu$(hostname)$def $(basename `pwd`)]\$ "; }
function execute()
{
printf "$cyn$(whoami)$def@$blu$(hostname)$def\$ "
prompt
type "$@" && wait
eval "$@"
}