[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Why ``color_prompt`` is only set for ``xterm``?



Hi

.bashrc on bullseye contains following lines

```
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac
```

So we only have colors in the terminal emulator, but not in virtual linux console.

This could be fixed by one more hardcode
``
    xterm-color|*-256color|linux) color_prompt=yes;;
``

But more robust way is something like:
```
if [ -x /usr/bin/tput ] && [ `/usr/bin/tput colors` -gt 1 ]; then
        color_prompt=yes
fi
```

I do not know how much people care about console these days, but why have hardcode if we can check the number of colors?

Ilya.

Reply to: