为什么 Debian 的默认 bash shell 是无色的?

Mic*_*cox 11 shell bash debian

我一直在寻找为什么默认的 Debian shell 是无色的,但找不到答案。

为什么 Debian shell (bash) 默认是无色的?

mau*_*wns 16

为什么 Debian shell (bash) 默认是无色的?

因此(从.bashrc香草 Debian 安装开始,重点是我的):

# 取消注释彩色提示,如果终端有能力;转身
# 默认关闭以不分散用户注意力:终端窗口中的焦点
# 应该在命令的输出上,而不是在提示上
#force_color_prompt=是

如果 [ -n "$force_color_prompt" ]; 然后
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; 然后
    # 我们有颜色支持;假设它符合 Ecma-48
    # (ISO/IEC-6429)。(缺乏这种支持是极其罕见的,而且这种
    # 一个案例倾向于支持 setf 而不是 setaf。)
    color_prompt=是
    别的
    颜色提示=
    菲
菲

换句话说,这是“功能”,或者如果您愿意的话,这是一种设计选择。

  • 这有点有趣,因为我发现当提示 **has** 颜色时更容易判断输出的位置。 (19认同)
  • 几年来,我一直在思考如何找到一个敢于在每个用户家中复制的文件中在不合逻辑的边界上写出如此荒谬的迂腐、咄咄逼人、毫无意义、完全有争议的文章的人。 (6认同)

Ste*_*itt 5

(问题的原始版本表明它与 root 的 shell 相关;我将它留在这里是因为它可能对特别想知道这个问题的用户有用。)

在 root 的情况下,默认提示是无色的,因为/etc/profile——或者更确切地说,/etc/bash.bashrc——定义了一个非常简单的提示:

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
Run Code Online (Sandbox Code Playgroud)

androot的默认值.bashrc不会覆盖它:

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022
Run Code Online (Sandbox Code Playgroud)

请参阅/root/.bashrc 和 /root/.profile 在 Debian 系统上从何而来?更多细节。