Blog | Admin | Archives

Screen and Vim with 256 colors

There are a few guides out and about about how to get your terminal up and running with 256 colors, which gives you a lot more options than the traditional 16 terminal colors that are enabled by default. I used several of these guides in coming up with my approach, but I had a few problems following these instructions. Eventually, through some trial and error, I found something that works, so I thought I’d share it here.

To get going quickly, you can just use my dotfiles, which I share on github and periodically update.

The key stuff I added for 256 colors are in these commits:

The key thing that was hard for me to get right was the tempcapinfo line in screenrc. The trial-and-error invovled putting my old termcapinfo and the new suggested termcapinfo together in different ways. Apparently, the correct answer was “append the new one to the old one” and then I was done. So, my screenrc’s termcapinfo line now looks like this:

termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l:Co#256:AF=\E[38;5;%dm:AB=\E[48;5;%dm:tc=screen:'

If anyone out there understand what in the world is going on there, please enlighten us in the comments!

Leave a Reply