-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathdemo-template.sh
More file actions
executable file
·81 lines (61 loc) · 1.61 KB
/
demo-template.sh
File metadata and controls
executable file
·81 lines (61 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
#################################
# include the -=magic=-
# you can pass command line args
#
# example:
# to disable simulated typing
# . ../demo-magic.sh -d
#
# pass -h to see all options
#################################
. ../demo-magic.sh
########################
# Configure the options
########################
#
# speed at which to simulate typing. bigger num = faster
#
# TYPE_SPEED=20
#
# custom prompt
#
# see http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html for escape sequences
#
DEMO_PROMPT="${GREEN}➜ ${CYAN}\W ${COLOR_RESET}"
# text color
# DEMO_CMD_COLOR=$BLACK
# hide the evidence
clear
# enters interactive mode and allows newly typed command to be executed
cmd
# put your demo awesomeness here
if [ ! -d "stuff" ]; then
pe "mkdir stuff"
fi
# print and execute: cd stuff
pe "cd stuff"
# ctl + c support: ctl + c to stop long-running process and continue demo
pe "ping www.google.com"
p "Entering reple mode. Type exit to leave repl mode"
repl
# print and execute: echo 'hello world' > file.txt
pe "echo 'hello world' > file.txt"
# wait max 3 seconds until user presses
PROMPT_TIMEOUT=3
wait
# print and execute immediately: ls -l
pei "ls -l"
# print and execute immediately: cat file.txt
pei "cat file.txt"
# and reset it to manual mode to wait until user presses enter
PROMPT_TIMEOUT=0
# print only
p "cat \"something you want to pretend to run\""
# run command behind
cd .. && rm -rf stuff
# enters interactive mode and allows newly typed command to be executed
cmd
# show a prompt so as not to reveal our true nature after
# the demo has concluded
p ""