You've got several options.
I think your best bet is to load one colorscheme in .vimrc
, and another in .gvimrc
(or in your case, just don't load a colorscheme in .vimrc
at all). The .gvimrc
colorscheme will only be loaded when you're running the GUI version of MacVim.
If you don't want to split your configuration across multiple files, you can also use a conditional like this one in .vimrc
:
if has('gui_running')
colorscheme mycrazycolors
endif
Finally, if you really do want to know the number of colors available, you can check the t_Co
setting:
:echo &t_Co
t_Co
is empty in the GUI version of MacVim, so you'll probably still want to use a variation of the has()
technique. In fact, the default .vimrc
does something similar to determine when to enable syntax highlighting:
if &t_Co > 2 || has("gui_running")
syntax on
endif
For the sake of completeness, I should mention that you could also expand your colorscheme file to include reasonable settings for color terminals. This is a fair amount of work, however, and it might be easier to just switch to a terminal application that supports more colors.
See these topics for more info:
:help has()
:help termcap
:help termcap-colors