Different vim colors and styles in Tmux and Gnome

colorsgnome-terminalterminaltmuxvim

I am using tmux, and recently found out that the same vim colorshemes inside and outside of tmux have different colors

Left is tmux in gnome-terminal, right is plain gnome-terminal, gnome-terminal has default colors:

![Left is <code>tmux</code> in <code>gnome-terminal</code>, right is plain <code>gnome-terminal</code>

EDIT: At closer look, the style does change too (look at bold etc).

Both terminals are 256-colored ones (gnome-terminal indicates himself as xterm-256color, tmux as tmux-256color, see ncurses-term package), vim sees that too (:set t_Co gives 256).
I compared their color representations via

for i in `seq 0 255` ; do echo -e "$i: \e[48;5;${i}m                  \e[0m"; done

And got the same palettes:

Color paletes

I think tmux should just pass these colors to gnome-terminal, but when why vim changes?

Can I fix this? I think gnome-terminal ones are better, and want tmux to use them.

Best Answer

For some reason, it was just a Vim issue: when started in tmux, it loaded default colorsheme, but when started from plain terminal, it loaded desert colorscheme but still calling it default when asked via :colorsheme. Forcing :colorsheme default resolved an issue, so I added colorsheme line in my ~/.vimrc and now it's OK.

I have no idea why Vim was doing that stuff, but forcing desired colorsheme works fine.

Related Question