The color code is basically clipped between "\ e [" and "m": \ e [32; 1 m
You can use \ e [0 m to disable color output. In particular, when B is set to 1, the highlighted and bold text is displayed.
Common color codes:
Foreground background color
--------------- 30 40 black 31 41 red 32 42 green 33 43 yellow 34 44 blue 35 45 purple 36 46 cyan 37 47 white
Code meaning
---------------- 0 OFF1 highlighted 4 underline5 flashing 7 reversed white display 8 invisible
Change the color of the prompt in ps1.
# Set PS1
PS1 = "\ u @ \ H \ e [32; 1 m [\ w] \ e [0 m \ $"
Change color in shell
#! /Bin/bash
#===================================================== ========================
# Text color change test
#===================================================== ========================
Echo "Pay attention to the current text color"
Echo-e "\ e [31; 42 m"
Echo "Pay attention to the current color"
Echo-e "\ e [0 m"
Echo "Restore text color"