-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCOLORS.sh
68 lines (60 loc) · 1.14 KB
/
COLORS.sh
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
#!/bin/bash
#
# Define some fancy colors, but only if connected to a terminal.
# Thus output to file will be not cluttered anymore
#
#
#
# Use this line in your script to source
# [ -f ${0%%${0##*/}}COLORS.sh ] && . ${0%%${0##*/}}COLORS.sh
#
[ -t 1 ] && {
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
RESET=$(tput setaf 9)
BOLD=$(tput bold)
NOATT=$(tput sgr0)
}||{
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
WHITE=""
RESET=""
BOLD=""
NOATT=""
}
TICK="${NOATT}[${GREEN}✓${NOATT}]${GREEN}"
CROSS="${NOATT}[${RED}✗${NOATT}]${RED}"
INFO="[I]${NOATT}"
WARN="${NOATT}[${YELLOW}W${NOATT}]${YELLOW}"
QST="[?]"
IDENT="${NOATT} "
MYNAME="${0##*/}"
msgok () {
echo -e "${TICK} ${1}${NOATT}\n"
}
msg () {
if [[ -z ${1} ]] ; then
echo -e "${NOATT}"
else
echo -e "${INFO} ${1}${NOATT}"
fi
}
msgwarn () {
echo -e "${WARN} ${1}${NOATT}">&2
}
msgfail () {
echo -e "${CROSS} ${1}${NOATT}">&2
}
msgheader() {
[ -z "${1}" ] && return 0
[ -t 1 ] || toilet -w 132 -f pagga -F border "${1}"
}