坑1:256 color support for vim background in tmux
解决终端颜色配置与 tmux 颜色配置不匹配问题。
原因
From the look of your .bashrc and .profile, the shells inside tmux are overriding the ‘default-terminal’ setting in your tmux conf. Something like this:
- tmux creates new shell with
TERM=screen-256color
- .bashrc/.profile run, set
TERM=xterm-256color
- vim runs, tries to use incorrect TERM for tmux
you can check this by running
echo $TERM
in a fresh tmux shell.
Tmux is relatively picky about having a terminal set correctly. If you can, set the term value in gnome-terminal’s configuration, not in your .bashrc. Failing that, surround those settings with a check for “screen” or “screen-256color” TERM, and don’t reset them in that case.
Tmux REALLY wants the terminal set to screen
or screen-256color
解决方法
This is what worked for me in #Ubuntu and #Mac:
# File: ~/.bashrc (Ubuntu), ~/.bash_profi