如何修改终端用户名颜色修改为红色(可以自由定制)

如何修改终端用户名颜色修改为红色

tipsbychsry: >表示终端输入,修改了乱码显示的问题,添加了截图显示。

整个操作代码流程图片和最终显示结果

输入>echo $PS1

显示:如上图

在个人用户文件夹输入

输入gedit ~/.bashrc

修改这几行代码

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi 
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

重改为:

# if [ "$color_prompt" = yes ]; then
#     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# else
#     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

其实也就是终端的PS1的设置注释掉然后在末尾一行重写。在末尾一行加上:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\h:\w\$ '

保存后退出,然后source一下,也就是输入>source ~/.bashrc

root文件夹里面位置 /root也同样操作一遍。

根据个人喜好可以自由定制,也可以这样修改:

customer:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\h:\[\033[01;33m\]\w\[\033[00m\]\$ '
root: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\h:\[\033[01;33m\]\w\[\033[00m\]\$ '

截图效果如下:

希望大家喜欢!!!

edit-in-2015-08-16-by-chsry

 

posted @ 2015-08-14 13:20  chsry  阅读(1314)  评论(0编辑  收藏  举报