forked from barbw1re/bash-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.sh
104 lines (82 loc) · 1.68 KB
/
demo.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# Ensure we are running under bash
if [ "$BASH_SOURCE" = "" ]; then
/bin/bash "$0"
exit 0
fi
#
# Load bash-menu script
#
# NOTE: Ensure this is done before using
# or overriding menu functions/variables.
#
. "bash-menu.sh"
################################
## Example Menu Actions
##
## They should return 1 to indicate that the menu
## should continue, or return 0 to signify the menu
## should exit.
################################
actionA() {
echo "Action A"
echo -n "Press enter to continue ... "
read response
return 1
}
actionB() {
echo "Action B"
echo -n "Press enter to continue ... "
read response
return 1
}
actionC() {
echo "Action C"
echo -n "Press enter to continue ... "
read response
return 1
}
actionX() {
return 0
}
################################
## Setup Example Menu
################################
## Menu Item Text
##
## It makes sense to have "Exit" as the last item,
## as pressing Esc will jump to last item (and
## pressing Esc while on last item will perform the
## associated action).
##
## NOTE: If these are not all the same width
## the menu highlight will look wonky
menuItems=(
"1. Item 1"
"2. Item 2"
"3. Item 3"
"A. Item A"
"B. Item B"
"Q. Exit "
)
## Menu Item Actions
menuActions=(
actionA
actionB
actionC
actionA
actionB
actionX
)
## Override some menu defaults
menuTitle=" Demo of bash-menu"
menuFooter=" Enter=Select, Navigate via Up/Down/First number/letter"
menuWidth=60
menuLeft=25
menuHighlight=$DRAW_COL_YELLOW
################################
## Run Menu
################################
menuInit
menuLoop
exit 0