linux 自定义命令提示符PS1

打开变量文件
vim ~/.bashrc

vim ~/.profile
添加内容
export OS=$(lsb_release -ds | sed 's/"//g')
export IP=`curl -s ip.sb`
export PS1="\u@$OS(\[\e[31m\]$IP\[\e[m\]):\W\\$ "
保存后,source一下
source ~/.bashrc

source ~/.profile
效果
liaozhiwei@Ubuntu 16.04.4 LTS(127.0.0.1):conf$