Getting 256 colors to work in tmux

The Tmux FAQ explicitly advises against setting TERM to anything other than screen or screen-256color or tmux or tmux-256color in your shell init file, so don't do it!

Here's what I use:

~$ which tmux
tmux: aliased to TERM=xterm-256color tmux

and in in my .tmux.conf:

set -g default-terminal "screen-256color"

Aliasing tmux to "tmux -2" should also do the trick.

And don't forget to restart your tmux server: (see @mast3r answer)

tmux kill-server && tmux

Try setting 256 colors explicitly in your bashrc or zshrc:

export TERM=xterm-256color

or

export TERM=screen-256color

If you have problems with tmux not clearing the background colors correctly when using the screen term setting, you can try:

export TERM=screen-256color-bce

As per the tmux FAQ, add this to your ~/.tmux.conf:

set -g default-terminal "screen-256color"

Then add this alias for tmux:

alias tmux='tmux -2'

No need to override the TERM variable in your profile or when starting tmux.

More information: http://vim.wikia.com/wiki/256_colors_setup_for_console_Vim