@@ -75,13 +75,50 @@ required_commands() {
75 return $exit_val
75 return $exit_val
81+# shellcheck disable=SC2034
82+set_terminal_colors() {
84+ _creset='\e[0m' # reset all attributes
109+if command -v fmt >/dev/null; then
78rst_title() {
115rst_title() {
79 # usage: rst_title <header-text> [part|chapter|section]
116 # usage: rst_title <header-text> [part|chapter|section]
81 case ${2-chapter} in
118 case ${2-chapter} in
82− part) printf "\n${1//?/=}\n$1\n${1//?/=}\n";;
119+ part) printf "\n${_BGreen}${1//?/=}\n$1\n${1//?/=}${_creset}\n";;
83− chapter) printf "\n${1}\n${1//?/=}\n";;
120+ chapter) printf "\n${_BGreen}${1}\n${1//?/=}${_creset}\n";;
84− section) printf "\n${1}\n${1//?/-}\n";;
121+ section) printf "\n${_BGreen}${1}\n${1//?/-}${_creset}\n";;
86 err_msg "invalid argument '${2}' in line $(caller)"
123 err_msg "invalid argument '${2}' in line $(caller)"
87 return 42
124 return 42
@@ -89,12 +126,6 @@ rst_title() {
92−if command -v fmt >/dev/null; then
98rst_para() {
129rst_para() {
99 # usage: RST_INDENT=1 rst_para "lorem ipsum ..."
130 # usage: RST_INDENT=1 rst_para "lorem ipsum ..."
100 local prefix=''
131 local prefix=''
@@ -106,9 +137,9 @@ rst_para() {
109−err_msg() { echo -e "ERROR: $*" >&2; }
140+err_msg() { echo -e "${_BRed}ERROR:${_creset} $*" >&2; }
110−warn_msg() { echo -e "WARN: $*" >&2; }
141+warn_msg() { echo -e "${_BBlue}WARN:${_creset} $*" >&2; }
111−info_msg() { echo -e "INFO: $*"; }
142+info_msg() { echo -e "${_BYellow}INFO:${_creset} $*" >&2; }
113clean_stdin() {
144clean_stdin() {
114 if [[ $(uname -s) != 'Darwin' ]]; then
145 if [[ $(uname -s) != 'Darwin' ]]; then
@@ -121,11 +152,14 @@ wait_key(){
122 clean_stdin
153 clean_stdin
123 local _t=$1
154 local _t=$1
124− local msg="${MSG:-** press any [KEY] to continue **}"
155+ local msg="${MSG}"
156+ [[ -z "$msg" ]] && msg="${_Green}** press any [${_BCyan}KEY${_Green}] to continue **${_creset}"
125 [[ ! -z $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
158 [[ ! -z $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
126 [[ ! -z $_t ]] && _t="-t $_t"
159 [[ ! -z $_t ]] && _t="-t $_t"
127 # shellcheck disable=SC2086
161 # shellcheck disable=SC2086
128− read -r -s -n1 $_t -p "$msg"
162+ read -r -s -n1 $_t
130 clean_stdin
164 clean_stdin
@@ -142,12 +176,12 @@ ask_yn() {
142 case "${2}" in
176 case "${2}" in
144 local exit_val=${EXIT_YES}
178 local exit_val=${EXIT_YES}
145− local choice="[YES/no]"
179+ local choice="[${_BGreen}YES${_creset}/no]"
146 local default="Yes"
180 local default="Yes"
149 local exit_val=${EXIT_NO}
183 local exit_val=${EXIT_NO}
150− local choice="[NO/yes]"
184+ local choice="[${_BGreen}NO${_creset}/yes]"
151 local default="No"
185 local default="No"
@@ -201,7 +235,7 @@ prefix_stdout () {
202 local prefix=" | "
236 local prefix=" | "
204− if [[ ! -z $1 ]] ; then prefix="$1"; fi
238+ if [[ ! -z $1 ]] ; then prefix="${_BYellow}$1${_creset}"; fi
206 # shellcheck disable=SC2162
240 # shellcheck disable=SC2162
207 (while IFS= read line; do
241 (while IFS= read line; do
@@ -270,17 +304,17 @@ choose_one() {
270 [[ ! -z $_t ]] && _t="-t $_t"
304 [[ ! -z $_t ]] && _t="-t $_t"
272 list=("$@")
306 list=("$@")
273− echo -e "Menu::"
307+ echo -e "${_BGreen}Menu::${_creset}"
274 for ((i=1; i<= $((max -1)); i++)); do
308 for ((i=1; i<= $((max -1)); i++)); do
275 if [[ "$i" == "$default" ]]; then
309 if [[ "$i" == "$default" ]]; then
276− echo -e " $i.) ${list[$i]} [default]"
310+ echo -e " ${_BGreen}$i.${_creset}) ${list[$i]} [default]"
278 echo -e " $i.) ${list[$i]}"
312 echo -e " $i.) ${list[$i]}"
281 while true; do
315 while true; do
282 clean_stdin
316 clean_stdin
283− printf "$1 [$default] "
317+ printf "$1 [${_BGreen}$default${_creset}] "
285 if (( 10 > max )); then
319 if (( 10 > max )); then
286 # shellcheck disable=SC2086
320 # shellcheck disable=SC2086
@@ -403,11 +437,11 @@ install_template() {
404 "interactiv shell")
438 "interactiv shell")
405 echo "// edit ${dst} to your needs"
439 echo "// edit ${dst} to your needs"
406− echo "// exit with CTRL-D"
440+ echo "// exit with ${_BCyan}CTRL-D${_creset}"
407 sudo -H -u "${owner}" -i
441 sudo -H -u "${owner}" -i
408 $DIFF_CMD "${dst}" "${template_file}"
442 $DIFF_CMD "${dst}" "${template_file}"
410− echo "did you edit file ..."
444+ echo "${_BBlack}did you edit file ...${_creset}"
411 printf " ${template_file}"
445 printf " ${template_file}"
412 if ask_yn "... to your needs?"; then
446 if ask_yn "... to your needs?"; then