prompt() now renders the real bash prompt on your system with a hack
This commit is contained in:
parent
24fca8ca4a
commit
64f673c00b
15
demo.sh
15
demo.sh
@ -4,12 +4,12 @@
|
|||||||
# type(): simulates typing its arguments
|
# type(): simulates typing its arguments
|
||||||
# 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)
|
# 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
|
||||||
# prompt(): prints a nice colored prompt
|
# prompt(): prints the bash PS1 prompt on your system with a nasty hack
|
||||||
|
|
||||||
TYPE_SPEED="${TYPE_SPEED:-15}"
|
TYPE_SPEED="${TYPE_SPEED:-15}"
|
||||||
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
|
PROMPT_TIMEOUT="${PROMPT_TIMEOUT:--1}"
|
||||||
@ -44,10 +44,13 @@ function wait()
|
|||||||
|
|
||||||
function prompt()
|
function prompt()
|
||||||
{
|
{
|
||||||
def="\033[0;00m"
|
invalidcmd="somethingthatshouldbetotallynotacommandinanygivenenvironment"
|
||||||
blu="\033[0;34m"
|
expPS1=$(echo $invalidcmd |
|
||||||
cyn="\033[0;36m"
|
bash -i 2>&1 |
|
||||||
printf "[$cyn$(whoami)$def@$blu$(hostname)$def $(basename `pwd`)]\$ ";
|
grep $invalidcmd |
|
||||||
|
head -n 1 |
|
||||||
|
sed "s/$invalidcmd//g")
|
||||||
|
printf "$expPS1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function execute()
|
function execute()
|
||||||
|
Loading…
Reference in New Issue
Block a user