Linux Command Prompt-Variable PS1 format

After the command line login, the system displays the command prompt: [root @ CentOS76 ~] # 

[root@CentOS76 ~]# 

[root@CentOS76 ~]# echo $PS1
[\u@\h \W]\$

The command prompt is defined by the variable "PS1" as follows:

 

A common usage is to color some fields:

cat /etc/profile.d/env.sh
##默认规范
#[\u@\h \W]\$

#开头\[\e[X;F;Bm\]   结尾\[\e[0m\]

#自定义将hostname部分加粗+下划线+标绿
PS1="[\u@\[\e[1;4;32;40m\]\h \[\e[0m\]\W]\\$ "
[root@CentOS76 ~]# 

Take effect immediately after synchronizing variable files

\e 字体修饰参数详解
\[\e[X;F;Bm\]

F=字体颜色
B=背景颜色

F    B    颜色
30    40    黑色
31    41    红色
32    42    绿色
33    43    黄色
34    44    蓝色
35    45    紫红色
36    46    青蓝色
37    47    白色

X
1    加粗
4    下划线
5    闪烁

 

Published 4 original articles · Likes0 · Visits 56

Guess you like

Origin blog.csdn.net/qq_24814027/article/details/105623569