added function color() to... well color stuff
This commit is contained in:
parent
d2cda8d290
commit
24fca8ca4a
16
demo.sh
16
demo.sh
@ -5,6 +5,7 @@
|
|||||||
# execute(): simuates typing then executing its arguments in a shell
|
# execute(): simuates typing then executing its arguments in a shell
|
||||||
# wait(): waits for user input with optional timeout
|
# wait(): waits for user input with optional timeout
|
||||||
# cmd(): gives control to user until she enters 'end' (or for a single command if you pass an argument).
|
# cmd(): gives control to user until she enters 'end' (or for a single command if you pass an argument).
|
||||||
|
# color(): allows you to color (second argument, defaults to $clr) some text (first argument)
|
||||||
#
|
#
|
||||||
# Helpers (internal stuff):
|
# Helpers (internal stuff):
|
||||||
# simtyping(): let's data piped to it through at rates similar to typing
|
# simtyping(): let's data piped to it through at rates similar to typing
|
||||||
@ -13,6 +14,21 @@
|
|||||||
TYPE_SPEED="${TYPE_SPEED:-15}"
|
TYPE_SPEED="${TYPE_SPEED:-15}"
|
||||||
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
|
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
|
||||||
|
|
||||||
|
# some colors
|
||||||
|
def="\033[0;00m"
|
||||||
|
wht="\033[1;37m"
|
||||||
|
red="\033[0;31m"
|
||||||
|
grn="\033[0;32m"
|
||||||
|
blu="\033[0;34m"
|
||||||
|
|
||||||
|
clr="$wht"
|
||||||
|
function color()
|
||||||
|
{
|
||||||
|
printf "${2:-$clr}"
|
||||||
|
printf "${1}"
|
||||||
|
printf "${def}"
|
||||||
|
}
|
||||||
|
|
||||||
function simtyping()
|
function simtyping()
|
||||||
{ pv -qL $(($TYPE_SPEED+$((-2 + RANDOM%5)))); }
|
{ pv -qL $(($TYPE_SPEED+$((-2 + RANDOM%5)))); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user