You are not logged in.

#1 2016-07-04 10:18:25

Starfish
Member
From: Germany
Registered: 2015-10-21
Posts: 134

[SOLVED] Interrelation of color settings between terminal, shell, etc.

I have the following general problem:
Suppose I want to change the color settings for editing a text file. In my case there are 4(!) programs where I can adjust them:
- shell (bash / .bashrc)
- terminal (xterm / .Xresources)
- terminal multiplexer (tmux / .tmux.conf)
- editor (vim / .vimrc)

It is easy to find out how to change the color in each of the programs by asking almighty google, but I want to know how they are interrelated.

To be more specific:
When I take a look at "top", I see the following order of forks: xterm->tmux->bash->vim. Does this mean that firstly the configuration of xterm is set, then the one of tmux and so on?
When two configuration collide, say I set color scheme "A" in bash and color scheme "B" in vim, what happens in general?
When I set a particular color, for example "foreground" to white in xterm, does the system bother to look for the "foreground"-configuration in vim, or is it more like "got it, you want white, so I dont even need to look in your .vimrc."?
Is there a certain hierarchy where one program's configuration outweighs the other?
Do some of the configurations depend on each other?

Any help is appreciated.

Last edited by Starfish (2016-07-04 15:26:48)


"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present." - Master Oogway

Offline

#2 2016-07-04 12:05:12

shmibs
Member
Registered: 2012-09-11
Posts: 93
Website

Re: [SOLVED] Interrelation of color settings between terminal, shell, etc.

since the terminal emulator is the program which does actual text rendering, it is what controls the actual colours rendered. 256 colour terminal emulators, like xterm, can render text using a choice from... 256 different colours (https://upload.wikimedia.org/wikipedia/ … _chart.svg). when you configure a colour scheme for a program which outputs to that terminal emulator, all you're doing is telling it which of those given 256 colours should be used for which purposes. a vim colour scheme, then, is a mapping between specific code elements and a selection from that given set of colours. in the case where something like tmux stands as an intermediary between the terminal emulator and another program (emulating an emulator, that is), it can rearrange those mappings as it chooses, for example, ensuring that any program which indicates text should be drawn in a #088 red should be drawn in #069 blue instead. it cannot, however, define new colours outside the set of 256, as it's not the thing doing the actual rendering.

to change how those 256 colours are mapped to the (usually 24bit) internal colour depth of the display server, then, you must configure that mapping at the terminal emulator level. from there, yet another mapping can be made, sometimes down to 18bit colour for cheap LCDs and sometimes upwards for systems with hardware support for more colours.

tl;dr: terminal emulator determines "actual colours", and anything run in that emulator can only choose from the provided palette

Last edited by shmibs (2016-07-04 12:06:05)


[site] | [dotfiles] | あたしたち、人間じゃないの?

Offline

#3 2016-07-04 12:46:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] Interrelation of color settings between terminal, shell, etc.

The above post caputures most of what I'd post as a reply - I'll add just a few points.  In most cases, tmux doesn't do anything with colors, provided that it has the settings to use 256 colors at least.  You shouldn't try to reset colors in tmux.

As for default foreground and background colors, these can be set in both the terminal emulator and vim (or mutt, etc).  Personally I like the uniform look of setting the default foreground and background in the terminal (Xdefaults) then just telling vim/tmux/tig/etc to use the default fg/bg.  But if you want vim, for example, to look distinctly different you can set a completely different background color.  So when vim starts, there is an obvious change.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2016-07-04 15:26:30

Starfish
Member
From: Germany
Registered: 2015-10-21
Posts: 134

Re: [SOLVED] Interrelation of color settings between terminal, shell, etc.

Thank you two, that's basically what I wanted to know!


"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present." - Master Oogway

Offline

Board footer

Powered by FluxBB