I’m a bit late to the game – 8 colours was clearly enough for me for a long time. Probably still is, but I thought I might join the late 90s and update to 256 colours.
This is written from the perspective of a Mac OS X user on 10.9.x, but some of the information might be useful elsewhere. In particular, the screen stuff.
If you’re on Mac OS X – the built in Terminal.app supports 256 colours I understand – but I use iTerm2. If you don’t already use it, I suggest you check it out.
Firstly, to find the number of colours your current terminal supports:
% tput colors
256
%
If that outputs ‘256’ everywhere you are, then you may not need to do anything – screen might be an exception for Mac users.
If it’s ‘8’, then you need to work on things a little. Fortunately, it doesn’t seem to be too difficult on modern systems at all. No need for scary termcap/terminfo lines from what I can tell.
To confirm that this is indeed working well, if the output is 256 (note, it won’t with , you can then check via a vim test – just run vim as so:
vim "+runtime syntax/colortest.vim"
You may also need to enter set t_Co=256 – add it to the end of your .vimrc file while testing – it can probably stay there forever, unless for some reasons you have systems that can’t support 256 colours.
[Need to insert screenshots here for best visibility of what’s wrong and right]
Firstly, check your terminal on your local machine:
% echo $TERM
xterm-256color
%
That’s the sort of output you want – other values may work for 256 colours, but I have not used them.
For me, it was simple to get this changed – go to your terminal program preferences, and simply select xterm-256color as your terminal option.
On iTerm2, this is under Profiles, and the Terminal tab. You can do it via “Edit Current Session”, but I am not sure that makes sense for a change like this, so I would do it via the profile preferences, and create a new terminal window after any changes.
After you’ve set the terminal, you can just go back and do the vim syntax test to see if all is OK now. It should be just fine!
Now, onto screen. This may have been more awkward in the past, but now, it seems to be very very simple.
If you’re on Mac OS X 10.9 at least, you will need to install a version of screen that has been compiled with 256 colour support. I use MacPorts.org, and simply did a ‘port install screen‘, and I was good to go. Seemingly no need to configure .screenrc to get 256 colour support, at least, not for vim.
tput colors, however, reports only 8. to fix that, simply add “term screen-256color” to your .screenrc.
echo "term screen-256color" >> ~/.screenrc
If you want to double check, then you can run a simple perl script that I found online. It gives a nice gradient display if 256 colors are enabled, and a blocky display if not. Pretty easy to see when it’s working and when it’s not.