Terminal.app magically changing color values [duplicate]

Terminal.app does some very odd color shifting that makes it impossible to match colors consistently, and I'm wondering if there is any way to disable it or better control it. The "magic" is what shows purple instead of blue, for example, even when the ansi color for the theme is set to plain blue.

This behavior appears to be tied to setting the background color... setting any background color (with terminfo setab capability) disables the "magic" color shift, while an attribute reset (sgr0) re-enables it.

This is my test (sets the foreground, prints some unicode filled blocks, explicitly sets the background to black, prints again):

b=$'\xE2\x96\x88' && bs=$b$b$b$b$b$b$b$b &&
  tput setaf 4 && echo -n "$bs" &&
  tput setab 0 && echo "$bs"

With the default theme, it prints purple (magic) then blue (ansi). So, my first attempt was to sample the purple color, and update the preferences to use that purple instead of blue... everything should be consistent now, right?

On the next run, I get a slightly brighter purple and then the purple I entered. At first I thought I just put the color in wrong, but as I kept brightening the color setting to match what Terminal.app was showing without the background set explicitly, the Terminal.app just kept getting brighter too -- all the way up until it was white!

From this, it seems to me that Terminal.app is automatically scaling the the colors displayed on the default background color by some factor, but it leaves colors on any explicitly set background alone; making it impossible for the two colors ever to match (except white and black).

FWIW, the window background is set to fully-opaque black.

Is there any way to get rid of this behavior? I'm thinking that this is maybe bug-report-worthy, but I'm curious if there is just something I'm missing.


In order to get the right color scheme the background needs to be explicitly declared inside LSCOLOR (gnu) or LS_COLOR (linux) and match the non-ANSI one set in your Terminal.app (i.e. Window > Background > Color and Effects).

So, something like LSCOLORS=eadafafacafafacacaeaea would work while something like LSCOLORS=exdxfxfxcxfxfxcxcxexex wouldn't.