script/lib/ansi: move 'normal' code definition below all others, so that 'sh -x'...
[CDN/Mosi.git] / script / lib / ansi.sh
1 # Include me for neat color defines!
2
3 if [ -z "${__ansi_sh_loaded}" ]
4 then
5   __ansi_sh_loaded=yes
6
7   # ANSI formats
8   e="$(printf "\033")"
9
10   # ANSI styles
11   a_bright="$e[1m"
12   a_dim="$e[2m"
13   a_italic="$e[3m"    # Probably won't work
14   a_underline="$e[4m" # Probably won't work
15   a_blink="$e[5m"     # Annoying; probably won't work
16   a_flash="$e[6m"     # Probably won't work
17   a_inverse="$e[7m"
18   a_conceal="$e[8m"   # Probably won't work
19   a_strike="$e[9m"    # Probably won't work
20
21   # ANSI colors
22   a_red="$e[1;31m"
23   a_green="$e[1;32m"
24   a_yellow="$e[1;33m"
25   a_blue="$e[1;34m"
26   a_purple="$e[1;35m"
27   a_cyan="$e[1;36m"
28   a_white="$e[1;37m"
29   a_gloom="$e[1;30m"
30
31   a_crimson="$e[0;31m"
32   a_forest="$e[0;32m"
33   a_brown="$e[0;33m"
34   a_navy="$e[0;34m"
35   a_violet="$e[0;35m"
36   a_aqua="$e[0;36m"
37   a_gray="$e[0;37m"
38   a_black="$e[0;30m"
39
40   a_bred="$e[41m"
41   a_bgreen="$e[42m"
42   a_bbrown="$e[43m"
43   a_bblue="$e[44m"
44   a_bpurple="$e[45m"
45   a_bcyan="$e[46m"
46   a_bgray="$e[47m"
47   a_bblack="$e[40m"
48
49   # Normal is at the bottom, otherwise debugging via 'sh -x' is difficult
50   a_normal="$e[0m"
51
52   a() {
53     while [ "${1}" ]
54     do
55       eval "echo \${a_$1}"
56       shift
57     done
58   }
59 fi