Change the prompt color in the shell terminal

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.