如何修改终端用户名颜色修改为红色
tipsbychsry: >表示终端输入,修改了乱码显示的问题,添加了截图显示。
整个操作代码流程图片和最终显示结果
images/loading.gif' data-original="http://images0.cnblogs.com/blog2015/780338/201508/141310080203147.png" width="469" height="157" />
修改这几行代码
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\$ '# fiunset 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;32m\]\u[\033[00m\]@\h\:\[\033[01;33m\]\w\[\033[00m\]\$ '
root:PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u[\033[00m\]@\h\:\[\033[01;33m\]\w\[\033[00m\]\$ '
截图效果如下: