Skip to content

[BUG] Need better detection of terminal color capabilities #1640

@quadrillion

Description

@quadrillion

Describe the bug
The terminal 'rxvt-unicode-256color' is not correctly identified as having 256 color support, because the code doesn't expect the base terminal name (rxvt-unicode) to have a hyphen (https://github.com/willmcgugan/rich/blob/master/rich/console.py#L773).

To Reproduce
Run urxvt from the rxvt-unicode-256 package.

Platform
Linux

Diagnose

$ python -m rich.diagnose
│ color_system = 'standard' │
│   is_interactive = True   │
│      is_terminal = True   │
│         no_color = False  |
$ python -m rich._windows
platform="Linux"
WindowsConsoleFeatures(vt=False, truecolor=False)
$ pip freeze | grep rich
rich==8.0.0

Recommendation
Query the terminal capabilities more directly, e.g.:

try:
    import curses
    curses.setupterm()
    num_colors = curses.tigetnum('colors')
except ModuleNotFoundError:
    pass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions