lose vim colorscheme in tmux mode

2019-01-20 20:58发布

I'm running iterm2 and when I'm in tmux mode the colorscheme I have set in vim does not show up. Only the color scheme I've set in iterm. If I run vim from shell the colorscheme appears correct - its only when I'm in tmux mode.

I've tried setting :colorscheme molokai when in vim (see screenshot below) and it doesn't change - again, the default colorscheme for iterm2 remains.

Am I missing some setting to iterm or tmux.conf? My dotfles are up on github here.

17条回答
We Are One
2楼-- · 2019-01-20 21:25

From the tmux man page, adding flag as following:

tmux -2

This -2 flag forces tmux to run on 256-color mode.

This works for me

查看更多
时光不老,我们不散
3楼-- · 2019-01-20 21:25

I didn't have much luck trying to export a different TERM or set default-terminal in my .tmux.conf.

My solution for fixing vim colors within tmux was adding this line to .tmux.conf:

set -g terminal-overrides 'xterm:colors=88'

I'm not sure why this override was needed given that my TERM=xterm and I have iTerm set to xterm as well, but it seems to work.

查看更多
Root(大扎)
4楼-- · 2019-01-20 21:28

I've removed the line set termguicolors, but it doesn't work. Setting set notermguicolors instead in the .vimrc works.

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-20 21:30

I had the same problem. Only difference was I am using solarize rather then molokai.

To fix the issue, I have set up an alias in ~/.bashrc:

alias tmux="TERM=screen-256color-bce tmux"

And set up the default-terminal option in ~/.tmux.conf:

set -g default-terminal "xterm"

Lastly, do $ source ~/.bashrc to load new alias.

查看更多
Evening l夕情丶
6楼-- · 2019-01-20 21:30

I tried all the solutions above and what finally worked for me is putting the following lines in .tmux.conf:

set -g default-terminal "xterm-256color"
查看更多
女痞
7楼-- · 2019-01-20 21:32

I needed vim to display correctly with tmux in terminal on ubuntu and cygwin/mintty on windows. I got it to work by combining the answers like this.

In .bashrc:

alias tmux="tmux -2"

In .vimrc:

" use 256 colors in terminal
if !has("gui_running")
    set t_Co=256
    set term=screen-256color
endif

" fix cursor display in cygwin
if has("win32unix")
    let &t_ti.="\e[1 q"
    let &t_SI.="\e[5 q"
    let &t_EI.="\e[1 q"
    let &t_te.="\e[0 q"
endif

based on answers from this question, this Vim wiki page and this block cursor question

查看更多
登录 后发表回答