相关的几个文件,或许更多
vim /etc/bash.bashrc
vim /etc/profile
vim ~/.bashrc
vim ~/.bash_profile
终端颜色由 PS1 变量进行定义,上面这些文件中就有 PS1 变量。
由于本人刚开始用Linux,从简单处入手比较适合。
1. 去掉 ~/.bashrc 中的 force_color_prompt=yes 注释,保存后并 source ~/.bashrc
之后如果终端颜色已经上色,这就达到目的了。
2. 终端执行 export TERM=xterm-256color 开启256真彩色试试结果
如果有效,把这行代码追加到 ~/.bashrc 或者 /etc/profile 文件的末行。
3. 试试下面的命令,其实就是开启 force_color_prompt=yes
cp /etc/bash.bashrc /etc/bash.bashrc.bak cat << EOF >> /etc/bash.bashrc # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi
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
EOF
4 . 如何定义颜色,这是一门特别的学问,建议 博客园 或者 知乎 咨询
鄙人已经江郎才尽了,如果可以,请告诉我这些