-
Notifications
You must be signed in to change notification settings - Fork 5
/
esccolors
69 lines (59 loc) · 1.47 KB
/
esccolors
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
69
#!/bin/bash
#17
NAMES=(Default Black DarkRed DarkGreen DarkYellow DarkBlue DarkMagenta DarkCyan Gray DarkGray Red Green Yellow Blue Magenta Cyan White)
FGROUND=(39 30 31 32 33 34 35 36 37 90 91 92 93 94 95 96 97)
BGROUND=(49 40 41 42 43 44 45 46 47 100 101 102 103 104 105 106 107)
#Reset code \x1b[0m
#Attributes 0-Default; 1-bold; 4-understrike; 5-blinking; 7-inversing; 8-invisible
echoc() #Text, color, background, attributes
{
if [ -z "$2" ];then
echo "$1"
return
fi
E__="\x1b[${FGROUND[$2]}m"
if [ -n "$3" ];then
E__="$E__\x1b[${BGROUND[$3]}m"
fi
if [ -n "$4" ];then
E__="$E__\x1b[$4""m"
fi
echo -e "$E__$1\x1b[0m"
}
echocn() #Text, color, background, attributes
{
if [ -z "$2" ];then
echo -n "$1"
return
fi
E__="\x1b[${FGROUND[$2]}m"
if [ -n "$3" ];then
E__="$E__\x1b[${BGROUND[$3]}m"
fi
if [ -n "$4" ];then
E__="$E__\x1b[$4""m"
fi
echo -e -n "$E__$1\x1b[0m"
}
echo -e "Foreground color:\tBackground color:"
for N in {0..16}; do
if [ $N -eq 1 ];then #foreground
echocn "$N - ${NAMES[$N]}" $N "16"
else
echocn "$N - ${NAMES[$N]}" $N
fi
echo -e -n "\t\t\t"
if [ $N -gt 1 ];then
echoc " ${NAMES[$N]} " 1 $N #background
else
echoc " ${NAMES[$N]} " 0 $N
fi
done
echo
echocn "Bold" 0 0 1; echo -n " "
echocn "Understrike" 0 0 4; echo -n " "
echocn "Blinking" 0 0 5; echo -n " "
echocn "Inversing" 0 0 7; echo -n " "
echocn "Invisible" 0 0 8; echo -n " "
echo
echo