sharkdp / vivid

A themeable LS_COLORS generator with a rich filetype datebase
Apache License 2.0
1.77k stars 87 forks source link

16-color fallback mode #21

Open neersighted opened 5 years ago

neersighted commented 5 years ago

A fallback to 16 colors would be great for those of us who use a terminal with a set color scheme locally, and rely on true color for unconfigured terminals or over ssh.

sharkdp commented 5 years ago

Thank you for the feedback!

How would this work? There is no fixed specification for those 16 colors, right? We wouldn't have any control over how the output looks like.

a terminal with a set color scheme locally, and rely on true color for unconfigured terminals or over ssh.

I don't quite understand. What does "terminal over ssh" mean? Aren't you still limited by your local terminal if you SSH anywhere else?

neersighted commented 5 years ago

There's no fixed specification, but most color schemes have a version for 16 color terminals. I'd prefer to have a pair of [rgb, 16-color index] in each theme, thus falling back to a configured terminal.

There are situations where I cannot rely on truecolor, such as SSH from mobile devices, or connections over mosh. I find it useful to fall back to a conventional colorscheme instead of corrupting the terminal.

sharkdp commented 5 years ago

There's no fixed specification, but most color schemes have a version for 16 color terminals.

Ok, that makes sense. Although we would have to rely on the users to have the same color scheme configured in their terminal (which they need anyway for a suitable background color).

There are situations where I cannot rely on truecolor, such as SSH from mobile devices, or connections over mosh. I find it useful to fall back to a conventional colorscheme instead of corrupting the terminal.

Oh I see, if you are connecting to your machine from another terminal.

How would we detect that? Can we get correct values of $COLORTERM/$TERM within an SSH session?

neersighted commented 5 years ago

The proper way is to use terminfo (try tput colors on a system with modern ncurses and TERM set to xterm-direct, for instance). Personally, I'd prefer to have it configured via a flag, so I can attach my own logic to the process.

neersighted commented 5 years ago

(Making the color mode tri-state and adding a 4-bit mode would be perfect)

neersighted commented 5 years ago

Also, themes could have automatic fallback support if they used the standard ANSI color names for 16 of their keys: black, red, green, blue, cyan, magenta, yellow, white (and bright variants of each)

pickfire commented 4 years ago

I would also like to see this since I wanted to use the default color of the terminal rather than the colors specified manually.

chtenb commented 2 years ago

Yes I would like this feature too. I think all we would need is a way to refer to a ansi colors in the theme format. Right now it seems we can only refer to "fixed" colors like

colors:
  background_color: '161821'

If we could to something like

colors:
  background_color: -1
  white: 1
  red: 2

then we could ship a theme that would only use the ansi colors.

setpill commented 3 months ago

+1 on this feature, with the addition that I'd like to be able to use a 256 colour palette, not just a 16 colour palette. Rationale being that I use a base16 theme in "compatible" mode (ie. using 22 colours), and I'd love if my LS_COLORS could respect my terminal colours, also e.g. when I switch theme.