centos:快速自定义专属终端命令提示符
参考链接:https://www.freesion.com/article/5148192299/
1.自定义主机名
hostnamectl set-hostname qingchen
bash
2.配置随空格在右上角显示时间或者特殊字符,Xshell中闪烁字体
编写脚本:
vim script-qingchen.sh
#!/bin/bash
#/etc/profile
#设置随机数
num=$[RANDOM%6+1]
#定义行数及列数
lines=`tput lines`
cols=`tput cols`
col=$[${cols}-12]
#tput cup 1 $col
tput setab ${num}
tput setaf 7
tput sc ;tput blink ; tput cup 2 ${col} ; echo '<qingchen>'; tput rc
tput sgr0
tput sc ; tput cup 0 ${col} ; echo ' '; tput rc
tput sc ; tput cup 1 ${col} ; echo ' '; tput rc
3.编辑/etc/profile文件
--脚本赋权
chmod 777 /qingchen/script/script-qingchen.sh
vim /etc/profile
--在最后加入下面一行
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}";/qingchen/script/script-qingchen.sh'
4.Shell命令提示符及颜色
是由PS1来配置
echo $PS1
PS1='[\[\e[36;40m\]\u@\h \[\e[0m\] \w \t]$ '
--这是我当前的
--这个随自己喜爱定颜色
-- \[\e[0m\] 作用就是个句号,不加后面的会跟着你配置的颜色走,可以自己试一下看看
PS1='[\[\e[33;40m\]\u@\h \w \t]$ '
-- PS1不是永久的,接下来写到配置文件里面
vim ~/.bashrc
--在最后加入
PS1='[\[\e[36;40m\]\u@\h \[\e[0m\] \w \t]$ '
-- 保存即可