Descripción: Script que mediante el uso de variables permite tener salidas más estéticas en pantalla.
#!/usr/bin/env bash
# Colores en bash
# JuszR gentoo@rocks.net
# GPL
# Variables
txtund=$(tput sgr 0 1) # Subrayado
txtbld=$(tput bold) # Negrita
bldred=${txtbld}$(tput setaf 1) # rojo
bldblu=${txtbld}$(tput setaf 4) # azul
bldwht=${txtbld}$(tput setaf 7) # blanco
txtrst=$(tput sgr0) # Resetear
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
echo "Ejemplos de colores"
echo -e "$(tput bold) norm negr subr tput-colores$(tput sgr0)"
for i in $(seq 1 7); do
echo " $(tput setaf $i)Texto$(tput sgr0) $(tput bold)$(tput setaf $i)Texto$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Texto$(tput sgr0) \$(tput setaf $i)"
done
echo -e '$(tput bold)' 'Para Negrita'
echo -e '$(tput sgr 0 1)' 'Para Subrayado'
echo -e "Ejemplo: "
echo -e "$(tput bold) Negrita" "$(tput sgr 0 1)Subrayado"
Para observar la salida del script
chmod +x colores.bash
./colores.bash
0 comentarios:
Publicar un comentario