Modify the Linux terminal command line Color
This article turns from: http://www.cnblogs.com/menlsh/archive/2012/08/27/2659101.html
The Linux operating system (Cent5.0) has been used recently because of work needs. I hate the way Linux terminals command the same style, and not easy to distinguish with the output content, it is easy to see eye. So on the Internet to find a way to modify the Linux terminal command line color, the way they have validated, and finally found an effective way to modify the Linux terminal command line color. (for example, under the root user work)
1.ps1
To modify the Linux terminal command line color, we need to use the PS1,PS1 is an environment variable for the Linux end user that describes the settings for the command line prompt. In the terminal input command: #set, you can find the definition of PS1 in the output as follows:
Ps1= ' [\u@\h \w]\$ '
The meaning of a commonly used parameter in the definition of PS1 is as follows:
\d: #代表日期, format weekday month date, for example: "Mon Aug 1"
\h: #完整的主机名称
\h: #仅取主机的第一个名字
\ t: #显示时间为24小时格式, such as: HH:MM:SS
\ t: #显示时间为12小时格式
\a: #显示时间为24小时格式: hh:mm
\u: #当前用户的账号名称
\v: #BASH的版本信息
\w: #完整的工作目录名称
\w: #利用basename取得工作目录名称, so only the last directory will be listed
\#: #下达的第几个命令
\$: #提示字符, if root, the prompt is: #, the average user is: $
From this we can know that the Linux default command-line prompt is: [Current user's account name @ host First name the last item in the working directory]#
2. Color setting
The format of the character color in PS1 is: \[\e[f; Bm\], where "F" is the font color, the number is 30-37, "B" is the background color, and the number is 40-47. The color table is as follows:
F B
30 40 Black
31 41 Red
32 42 Green
33 43 Yellow
34 44 Blues
35 45 Purple-red
36 46 Green Blue
37 47 White
Depending on the color table, you can personalize the Linux terminal command line color by applying it to the character color formatting. For example, to set the format of the command line is green word black bottom, display the current user's account name, the host's first name, the full current working directory name, 24-hour format time, you can use the following command:
#PS1 = ' [\[\e[32;40m\]\u@\h \w \t]$ '
3. Modify the. bashrc file
Through the above settings can only change the current terminal command line format, close this terminal, in a reopened terminal command line format will revert to the default form. To permanently change the terminal command line format, you need to modify the. bashrc file.
Using commands: #cd/
#ls-L-A
You can see. bashrc this file. Using commands
#gedit. BASHRC
Add in the. bashrc file
Ps1= ' [\[\e[32;40m\]\u@\h \w \t]$ '
This statement, and then save, you can permanently change the terminal command line format.