Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the 256-color palette change in terminal VIM on OS X?

I have been playing with color schemes for terminal VIM and have found something annoyingly frustrating that I have been unable to solve thus far.

I expect the 16 system colors to change. They are obviously configurable. For that reason, I attempted to use the 256-color palette to construct a VIM color scheme that would be the same regardless of the terminal's 16 (configurable) system color palette.

I used only colors from the 256 color palette for everything, including background. However, I noticed that if I open terminals with different background and text colors specified for the terminals, the VIM color schemes appear quite different in the two terminals.

I do not see similar behavior on Ubuntu even when the terminals have different background, foreground, AND system color palettes.

I will happily accept an answer that explains why this happens.

I will be ecstatic if someone can tell me a way around this beyond setting up a specific terminal for each set of color settings I want to use.

like image 652
toadjamb Avatar asked Apr 01 '12 18:04

toadjamb


2 Answers

By default, ANSI terminals are 16 color devices and the Vim color schemes that work in gvim will not work properly in a terminal.

Some terminals are capable of 88 or 256 colors. You can tell Vim about this by setting t_Co. Of course, 256 colors is still less than full RGB that you have in gvim.

There is a package for vim called CSApprox developed by Matt Wozniski. It lets you use the gvim color schemes with approximate colors.

This is what I use myself.

CSApprox includes a documentation file which explains everything better than I can here.

URL: http://www.vim.org/scripts/script.php?script_id=2390

Good luck.

P.S. about your question However, I noticed that if I open terminals with different background and text colors specified for the terminals, the VIM color schemes appear quite different in the two terminals.

That sounds like the OSX terminal does not separate the color definition from the 256 color xterm palette; i.e. that by manipulating its settings you're messing with the palette or something like that.

Terminals should probably be keeping the 16 color user-configurable stuff separate from the 256 color palette.

like image 174
Kaz Avatar answered Nov 15 '22 18:11

Kaz


Terminal dynamically adjusts some color values to ensure a minimum amount of contrast with the background color. Perhaps that’s what you’re seeing.

Please attach a screenshot showing the two different color schemes. A good script for viewing the available colors is 256colors2.pl.

like image 40
Chris Page Avatar answered Nov 15 '22 18:11

Chris Page