show colored word in bash

  1. 1. echo color in bash console
  2. 2. color matrix

echo color in bash console

1
echo -e "\033[01;32m 绿色字体 √ \033[0m"
1
console.log('\033[01;32m', '绿色字体 √')

color matrix

1
2
3
4
5
6
7
8
9
for (let i = 0; i < 64; i++) {
for (let j = 32; j < 48; j++) {
const ii = i.toString().padStart(2, '0')
const jj = j.toString().padStart(2, '0')
const str = '\033' + `[${ii};${jj}m` + `[${ii};${jj}m` + '\033[0m '
process.stdout.write(str)
}
process.stdout.write('\n')
}