Skip to content

Color themes schemes

c-blake edited this page Nov 22, 2023 · 5 revisions

"Night Mode" and "Day Mode"

If one color theme/scheme works for you then you can just define it all in ~/.config/cligen and be done. If not, the idea of $LC_THEME helps. (Any variable name works, really.)

If ~/.config/cligen/config has [include__LC_THEME] then the default clCfgInit and clCfgToml parsers both merge the file ~/.config/cligen/$LC_THEME (or merge an absolute path if $LC_THEME starts with '/'). This environment-sensitive level of indirection for color aliasing is all that's needed. All you need to do is arrange for your terminal environment to have LC_THEME set correctly, e.g. two wrapper xterm launch scripts that do LC_THEME=lightBG xterm -bg white -fg black and LC_THEME=darkBG xerm -bg black -fg white. Then you make supporting color alias files like: "day mode" & "night mode".

Those two examples use the nearly ubiquitous 16-color xterm/ANSI codes from the early 1990s, but are only a subset of what cligen supports. The full attribute syntax is described in Text Attributes supported in Config files.

E.g., I find false color heat map/rainbow schemes easy to remember. So, defining colors = "fhue1 = BLUE" in a darkBG file and colors = "fhue1 = blue" in a lightBG file as the above two files do allows me to use "fhue1" in the "outer"/"real" config with confidence that it won't be nearly invisible dark blue on black text. For other color scheme ideas in various command utility settings, you might check out https://github.com/c-blake/bu/blob/main/doc/dfr.md#configuration .

ssh interactions

ssh (up to recent versions) by default propagates any LC_* environment var. So, if I set LC_THEME=darkBG in the shell environment of a dark terminal, this will be inherited and even sent to remote hosts across ssh as long as my remote ~/.config/cligen/ is set up correctly.

Recent sshd versions specifically white list each LC_ name. So, server admins must add AcceptEnv LC_THEME to /etc/ssh/sshd_config or if admin access is unavailable you can hijack any by-default-propagated-but-elsewise-unused name, e.g. LC_PAPER, since printing may be very unlikely. (You can always set a local LC_THEME based on the client LC_PAPER & then fix/unset LC_PAPER.) The above is all a lot of words for ultimately a very simple mechanism.