ubuntu-修改root用户终端显示颜色-bash

问题:root用户下,命令行没有高亮,看起来非常的累;

image

在root下编辑:

vim ~/.bashrc

看到:

 36 # uncomment for a colored prompt, if the terminal has the capability; turned37 # off by default to not distract the user: the focus in a terminal window38 # should be on the output of commands, not on the prompt39 force_color_prompt=yes40 41 if [ -n "$force_color_prompt" ]; then42     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then43         # We have color support; assume it's compliant with Ecma-4844         # (ISO/IEC-6429). (Lack of such support is extremely rare, and such45         # a case would tend to support setf rather than setaf.)46         color_prompt=yes47     else48         color_prompt=49     fi50 fi51 52 if [ "$color_prompt" = yes ]; then53     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '54 else55     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '56 fi57 unset color_prompt force_color_prompt58 

force_color_prompt 前面的# 去掉就行了

官方不建议root用户开启颜色,但是我不习惯

结果:

image