Reference <prompt magic>
Ubuntu Initial bash prompt color is the same as the program output color, when a large number of output, it is often difficult to find out where the output information began. If you turn the color of the prompt into a more eye-catching color, it's easy to locate the output information at the beginning.
When you want to change the prompt color in bash, you can set it by the value of the PS1 variable, and if you put it in the. bashrc file in the user's corresponding directory, the user automatically changes the color when you open bash. Here, I change the prompt to green:
ps1= "\[\e[32m\]\[email protected]\h:\w\$ \[\e[0m]"
Here, the value between \e[and M is shaped like xx:xx, which indicates the foreground: background color. No background color refers to the system settings and is not specified separately. A value of 0 in \e[0m means that the initial value is restored, and the effect here is not to change the color of the user entering data after the prompt.
The characters between \[and \] Do not occupy space, which is required when there is too much input data (more than one line).
\u represents the user name
\h Host Name
\w current Directory
\$ user prompt, when root user becomes #
The remaining non-escaped characters are printed directly.
Change the prompt color by setting the PS1 variable in bash