-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathechoc
executable file
·39 lines (33 loc) · 844 Bytes
/
echoc
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
#!/bin/bash
# Color echo
# Autor: Alejandro Hurtado
#
shopt -s expand_aliases #important for alias
alias reset_color='tput sgr0'
#alias reset_color='echo -ne \E[0m' #reset foolproof in v-terminals
#colors
export black='30'
export red='31'
export green='32'
export yellow='33'
export blue='34'
export magenta='35'
export cyan='36'
export white='37'
# Color-echo.
# use: echoc color "message" "b/u" color_background
# i.e: echoc $blue "Mensaje de prueba en azul y bold con fondo blanco" "b" $white
echoc ()
{
local default_msg=""
message=${2:-$default_msg} # Defaults to default message.
color=${1:-$white} # Defaults to white, if not specified.
bg=${4:-"30"}
bg1=$(expr $bg + 10)
if [[ "$3" == "b" ]]; then
bold="1;"
fi
echo -ne "\E[${bold}${color};${bg1}m $message"; reset_color
return
}
export -f echoc