河汉清且浅,牵牛敦而纯
随笔 - 77,  文章 - 0,  评论 - 1,  阅读 - 67049

相关的几个文件,或许更多

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
fiif [ "$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 . 如何定义颜色,这是一门特别的学问,建议 博客园 或者 知乎 咨询

鄙人已经江郎才尽了,如果可以,请告诉我这些

 

    

posted on   伊索  阅读(2813)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!

点击右上角即可分享
微信分享提示