The cue color in the shell terminal is determined by the PS1 in the environment variable, so change the PS1.
1> Temporary changes
[[Email protected]~]# echo $PS 1 [\[email protected]\h\w]\$ [email protected]~]# ps1= ' \[\033[31m\][\[email prote cted]\h\w]\[\e[0m\]\\$ "[[Email protected]~]#
Use echo $PS 1 to view the value of the PS1 at this time, and then give PS1 a color-weighted value. \[\033[31m\] \033[31m in order to display the subsequent font as red, 31m for red, and 0m to end the coloring of the text. \033[equivalent to \e[if you want to display colors in a terminal print, you need to start with one of these two. The start and end use \[and \] is to not affect the command prompt in PS1, if PS1 do not use \[and \], enter the long command in the terminal (especially when the line break will appear ' after the input to overwrite the preceding input ' problem). It is also possible to start and end without \[and \] When the shell script or terminal prints characters, without error.
2> Permanent Changes
write ps1= "\[\033[31m\][\[email protected]\h\w]\[\e[0m\]\\$" to the. bashrc file in the user's home directory; If you want to take effect immediately, use source. BASHRC or. The BASHRC command reloads the. bashrc file or assigns a value to PS1 using a method that is temporarily changed, using the latter
Reference http://www.cnblogs.com/ccorz/p/5523297.html
This article is from the "Gan mu" blog, please be sure to keep this source http://ganmu.blog.51cto.com/9305511/1858358
Change the prompt color in the shell terminal