Linux修改命令提示符


修改命令提示符脚本:

 1 [12:36:38 root@bj-aly-wordpress-251-93 shell_script]#cat set_env.sh 
 2 #!/bin/bash
 3 #
 4 #*************************************************************************************
 5 #Author:                                                      wanghaomiao
 6 #QQ:                                                          1074035975
 7 #Date:                                                        2022-03-31
 8 #FileName                                                     set_env.sh
 9 #URL:                                                         wanghaomiao.com.cn
10 #Description:                                                 The test script
11 #Copyreght (C):                                               2022 All rightsreserved
12 #*************************************************************************************
13 COLOR='\e[1;32m'
14 COLOR_END='\e[0m'
15 ENV_DIRECTORY=/etc/profile.d/env.sh
16 
17 set_env() {
18 echo 'PS1="[\[\e[1;31m\]\t\[\e[0m\] \u@\h \W]\\$"' > $ENV_DIRECTORY
19 chmod +x $ENV_DIRECTORY
20 echo -e "$COLOR 命令提示符设置完成!$COLOR_END"
21 }
22 source $ENV_DIRECTORY
23 set_env

注:需使用source或' . '执行。