refactored prompt drawing to separate function
This commit is contained in:
parent
d1f16360e5
commit
101d4b36b1
12
demo.sh
12
demo.sh
@ -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 "$@"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user