forked from barbw1re/bash-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.sh
75 lines (62 loc) · 1.22 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
#!/bin/bash
# Ensure we are running under bash
if [ "$BASH_SOURCE" = "" ]; then
/bin/bash "$0"
exit 0
fi
# Load bash-menu script
# Ensure the path is correct to locate bash-menu.sh
. "/path/to/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
# Ensure uniform width for better menu highlight appearance
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