Skip to content

Suggestion: add RGB color support #4

@aremmell

Description

@aremmell

Even though my terminal reports that it's xterm-256color, it supports RGB TrueColor. Every modern terminal I've tested with do as well. The format is similar to what you're already using. You could just add a color picker wheel and you'd be done.

The syntax is

\e[<attr>;<fg|bg>;2;<rrr>;<ggg>;<bbb>mHello, world\e[0m

Where:

  • attr is the normal/bold/emphasis, etc.
  • fg is 38, bg is 48 (to set default fg or bg, use 39 and 49, and omit the colors)
  • 2 is the RGB color mode
  • <rrr>;<ggg>;<bbb> is an RGB tuple: 80;201;45

You can also chain foreground and background commands together:

\e[0;38;2;80;201;45;48;2;0;0;0\0m

This is example random (literally) colors in RGB mode from my logging library:

Screenshot 2023-07-16 at 16 11 02

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions