Falling back to 256-colour palette

When ssh-ing from a friend or family-member’s machine instead of my own, I often find myself using older terminals which support the 256-colour xterm palette but not 24-bit RGB colour. (Rxvt-unicode and the MacOS built-in Terminal.app are examples that spring to mind.)

It’s probably a bit niche for upstream — hopefully non-RGB terminals are a vanishing breed! — but in case anyone else finds themselves in a similar situation, I just tidied up a local patch which adds an option to transparently map RGB colours to an appropriate entry in the 256-colour palette so you don’t have to drop right back to a 16-colour scheme.

Introduce optional fallback to the 256-color palette · arachsys/kakoune@c512528 · GitHub

It’s only doing simple RGB quantisation to the 6x6x6 cube, with a special case for the 24 scales of grey, but it works pretty well. Here’s kaleidoscope-light 24-bit on the left vs 256-colour on the right:

and here’s base16 24-bit on the left vs 256-colour on the right:

You can see colours aren’t quite identical but aren’t a bad match either: certainly much nicer than being restricted to 16 colours.

1 Like