aboutsummaryrefslogtreecommitdiffstats
path: root/bin/colcol
blob: 5a4ff50ee7d22a315a437248792c202c30785891 (plain) (blame)
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
#!/usr/bin/gawk -f
#colorizes a columnar output
BEGIN {
  colors[1] = "\x1b[38;5;216m"
  colors[2] = "\x1b[38;5;192m"
  colors[3] = "\x1b[38;5;22m"
  colors[4] = "\x1b[38;5;25m"
  colors[5] = "\x1b[38;5;98m"
  colors[6] = "\x1b[38;5;68m"
  colors[7] = "\x1b[38;5;59m"
  colors[8] = "\x1b[38;5;36m"
  colors[9] = "\x1b[38;5;202m"
  colors[10] = "\x1b[38;5;100m"
  colors[11] = "\x1b[38;5;105m"
  colors[12] = "\x1b[38;5;106m"
  colors[13] = "\x1b[38;5;96m"
  colors[14] = "\x1b[38;5;31m"
  colors[15] = "\x1b[38;5;23m"
  colors[16] = "\x1b[38;5;105m"
  colors_len=16
}
{
  if (1 == NR){
    max_col = NF
  }
  printf NR-1" "
  for (i = 1; i <= NF; i++){
    if (i >= colors_len) {
      printf "",colors[colors_len]$i" "
    } else {
      printf colors[i]$i" "
    }
  }
  print "\033[0m"
}