You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
3.5 KiB
138 lines
3.5 KiB
#!/bin/bash
|
|
############################################################################
|
|
#
|
|
# Utilización: fnc_gonzy.sh
|
|
# Versión: 20251010
|
|
# Mis funciones y otras utilerias utilizadas
|
|
# en mis scripts bash shell.
|
|
#
|
|
# Funciones:
|
|
# center_text($1 texto)
|
|
# # Centra $1 en el parrafo.
|
|
# display_center($1)
|
|
# # Centra varias lineas. Incluso
|
|
# # puede ser todo un archivo.
|
|
# fnc_gonzy_intro($1 $2 $3)
|
|
# # Imprime Titulo $1, Descripcion $2
|
|
# y alguna nota $3 para identificar
|
|
# la utilidad y uso de la funcion.
|
|
#
|
|
# Opciones:
|
|
# - Colores y estilos de fuentes.
|
|
# https://soloconlinux.org.es/colores-en-bash/
|
|
#
|
|
# Limitaciones:
|
|
# -
|
|
#
|
|
############################################################################
|
|
|
|
# Reset
|
|
Color_Off='\033[0m' # Text Reset
|
|
|
|
# Regular Colors
|
|
Black='\033[30m' # Black
|
|
Red='\033[31m' # Red
|
|
Green='\033[32m' # Green
|
|
Yellow='\033[33m' # Yellow
|
|
Blue='\033[34m' # Blue
|
|
Purple='\033[35m' # Purple
|
|
Cyan='\033[36m' # Cyan
|
|
White='\033[37m' # White
|
|
|
|
# Bold
|
|
BBlack='\033[1;30m' # Black
|
|
BRed='\033[1;31m' # Red
|
|
BGreen='\033[1;32m' # Green
|
|
BYellow='\033[1;33m' # Yellow
|
|
BBlue='\033[1;34m' # Blue
|
|
BPurple='\033[1;35m' # Purple
|
|
BCyan='\033[1;36m' # Cyan
|
|
BWhite='\033[1;37m' # White
|
|
|
|
# Cursive
|
|
CBlack='\033[3;30m' # Black
|
|
CRed='\033[3;31m' # Red
|
|
CGreen='\033[3;32m' # Green
|
|
CYellow='\033[3;33m' # Yellow
|
|
CBlue='\033[3;34m' # Blue
|
|
CPurple='\033[3;35m' # Purple
|
|
CCyan='\033[3;36m' # Cyan
|
|
CWhite='\033[3;37m' # White
|
|
|
|
# Underline
|
|
UBlack='\033[4;30m' # Black
|
|
URed='\033[4;31m' # Red
|
|
UGreen='\033[4;32m' # Green
|
|
UYellow='\033[4;33m' # Yellow
|
|
UBlue='\033[4;34m' # Blue
|
|
UPurple='\033[4;35m' # Purple
|
|
UCyan='\033[4;36m' # Cyan
|
|
UWhite='\033[4;37m' # White
|
|
|
|
# Background
|
|
On_Black='\033[m' # Black
|
|
On_Red='\033[m' # Red
|
|
On_Green='\033[m' # Green
|
|
On_Yellow='\033[m' # Yellow
|
|
On_Blue='\033[m' # Blue
|
|
On_Purple='\033[m' # Purple
|
|
On_Cyan='\033[m' # Cyan
|
|
On_White='\033[m' # White
|
|
|
|
# High Intensity
|
|
IBlack='\033[90m' # Black
|
|
IRed='\033[91m' # Red
|
|
IGreen='\033[92m' # Green
|
|
IYellow='\033[93m' # Yellow
|
|
IBlue='\033[94m' # Blue
|
|
IPurple='\033[95m' # Purple
|
|
ICyan='\033[96m' # Cyan
|
|
IWhite='\033[97m' # White
|
|
|
|
# Bold High Intensity
|
|
BIBlack='\033[90m' # Black
|
|
BIRed='\033[91m' # Red
|
|
BIGreen='\033[92m' # Green
|
|
BIYellow='\033[93m' # Yellow
|
|
BIBlue='\033[94m' # Blue
|
|
BIPurple='\033[95m' # Purple
|
|
BICyan='\033[96m' # Cyan
|
|
BIWhite='\033[97m' # White
|
|
|
|
center_text() {
|
|
local text="$1"
|
|
local cols=$(tput cols)
|
|
local text_len=${#text}
|
|
local padding=$(( (cols - text_len) / 2 ))
|
|
printf "%*s%s%*s\n" $padding "" "$text" $padding ""
|
|
}
|
|
|
|
display_center() {
|
|
local columns=$(tput cols)
|
|
while IFS= read -r line; do
|
|
local line_len=${#line}
|
|
local padding=$(( (columns - line_len) / 2 ))
|
|
printf "%*s%s%*s\n" $padding "" "$line" $padding ""
|
|
done < "$1"
|
|
}
|
|
|
|
function fnc_gonzy_intro(){
|
|
clear
|
|
echo -e "${UWhite}"
|
|
center_text $1
|
|
echo -e "${Color_Off}${CWhite}$2${Color_Off}${UWhite}"
|
|
center_text $3
|
|
echo -e "\n${Color_Off}"
|
|
}
|
|
|
|
function fnc_msg_color(){
|
|
if [[ $1 == 0 ]]; then
|
|
echo -e "[ \e[31mx\e[0m ] $2"
|
|
elif [[ $1 == 1 ]]; then
|
|
echo -e "[ \e[32m✓\e[0m ] $2"
|
|
elif [[ $1 == 2 ]]; then
|
|
echo -e "[ \e[33m…\e[0m ] $2"
|
|
elif [[ $1 == 3 ]]; then
|
|
echo -e "[ \e[33m!\e[0m ] $2"
|
|
fi
|
|
} |