256-color support under GNU screen, including non-GUI vim

Finally, I got 256-color support under GNU screen, including vim! I really don’t know how or why this was so difficult for me to get working, but it was a royal time sink. I read just about every thread everywhere about anything related to this topic.

All I can say is: This worked for me.

I’ve turned off comments on this post, because I don’t want to even begin to suggest that I will have any answers to any questions you may ask.

# .bash_profile
#
# I recursively copied /usr/share/lib/terminfo on a modern
# Linux box to $HOME/.terminfo so that I could have modern
# stuff with me wherever I go, like Solaris 10 which has
# no modern 256 color crap.  Make sure you have the screen-256color
# terminfo stuff.  Then...
TERMINFO=$HOME/.terminfo
# xterm-256color should work below as well, but since I am
# always connecting from PuTTY, I use this which is technically
# more correct.
TERM=screen-256color
# .screenrc portion for GNU screen which MUST BE compiled with 256
# color support.
#
term "screen-256color"
" .vimrc portion
"
" "People" say this should never be required if your terminfo crap is
" correct, but it is required for me *when running vim under GNU screen*
set t_Co=256

" Enable syntax highlighting
syntax enable

" Use whatever you like here
colorscheme lucius

" Dunno, this seems to be the only thing that leaves my terminal in a
" proper state once I exit vim in 256-color mode under GNU screen
" when using either TERM=putty-256color or TERM=xterm-256color.  Found it
" mentioned in some IRC log after digging through Google results for an
" hour or more.
set t_ti= t_te=