summaryrefslogtreecommitdiff
path: root/src/generate_colors.sh
blob: 3d2ba9310cd44db2294f38414caddf6c7a4c2aef (plain)
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
#!/bin/sh

PREFIX=$1

headerfile=${PREFIX}"/include/colors.h"
shlib=${PREFIX}"/lib/colors.sh"

cat > $shlib << "EOF"
#
# colors.h
#
# list of ansi color codes
# provided by xiutils
#

EOF

cat > $headerfile << "EOF"
/*
 * colors.h
 *
 * list of ansi color codes
 * provided by xiutils
 *
 */

EOF

append_header() {
    echo "#define $1 $2" >> $headerfile
}

append_sh() {
    echo "export $1=$2" >> $shlib
}

while IFS= read -r line; do
    grep -q "." <<< "$line" || continue
    name=$(echo $line | awk '{ print $1 }')
    code=$(echo $line | awk '{ print $2 }')

    append_header $name $code
    append_sh $name $code
    
done < "$2"