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
| #!/bin/bash
trap `get_window_size` WINCH # trap when a user has resized the window
_UNDERLINE_ON=`tput smul` # turn on underline
_UNDERLINE_OFF=`tput rmul` # turn off underline
get_window_size() {
_WINDOW_X=`tput lines`
_WINDOW_Y=`tput cols`
_FULL_SPACES=`echo ""|awk `
{
_SPACES = `${_WINDOW_Y}`
while (_SPACES-- > 0) printf (" ")
}'`
_FULL_UNDERLINE=`echo "${_UNDERLINE_ON}${_FULL_SPACES}${_UNDERLINE_OFF}"`
unset _FULL_SPACES
show_menu
return 0
}
set_color() {
tput clear
PS3="Enter Selection[1-9]:"
select _COLOR in "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" "Exit"
do
case ${REPLY} in
[1-8]) _X=`expr ${REPLY} - 1`;;
9) break;;
*) echo "Invalid Color"; continue;;
esac
if [[ ${1} = "b" ]]
then
tput setb ${_X}
else
tput setf ${_X}
fi
done
}
show_menu() {
while [[ -z ${_ANS} ]]
do
tput civis
tput clear
cat <<- EOF
Window Size: ${_WINDOW_X} / ${_WINDOW_Y}
Select => ${_UNDERLINE_ON} ${_UNDERLINE_OFF}
${_FULL_UNDERLINE}
B) Background Text Color
F) Foreground Text Color
X) Exit
EOF
tput rc
tput smul
tput cnorm
read _ANS
tput rmul
case ${_ANS} in
[Bb]) set_color "b";;
[Ff]) set_color "f";;
[Xx]) tput clear; exit;;
*)
echo -e "Invalid Selection: ${_ANS}\c"
sleep 2
;;
esac
unset _ANS
done
}
tput sgr0
tput civis
tput clear
tput cup 3 10
tput sc
tput cup 0 0
[[ -n ${_ANS} ]] && unset _ANS
get_window_size
exit 0
|