我正在运行iterm2,当我在tmux模式下,我在vim中设置的配色方案不显示。只有我设定的配色方案。如果我从shell运行vim,配色方案显示正确-只有当我在tmux模式。

我尝试过在vim中设置:colorscheme molokai(见下面的截图),它没有改变-再次,iterm2的默认配色方案保持不变。

我是否遗漏了对iterm或tmux.conf的一些设置?我的图都在github上。


当前回答

如果你使用tmuxinator或mux,你需要在.bashrc或.zshrc中添加这些:

alias tmux='TERM=screen-256color tmux -2'
alias tmuxinator='TERM=screen-256color tmuxinator'
alias mux='TERM=screen-256color mux'

这些力用256色在终端上。

然后tmux, tmuxinator和mux命令都将工作。

其他回答

如果有人需要24位颜色支持:

Tmux从2.2版开始支持24位颜色。如果您的终端支持24位颜色,请将您的终端添加到终端覆盖设置。例如,

set -ga terminal-overrides ",xterm-256color:Tc"

我的环境清单:

macOS Sierra 10.12.3 iTerm2 3.0.14(报表终端类型为xterm-256color) neovim 0.1.7(通过添加:xterm-256color到.vimrc来启用24位颜色) tmux 2.3(在.tmux.conf中添加set -ga terminal-override ",xterm-256color:Tc")

我不需要在.bashrc或.zshrc中添加任何其他内容。

希望这能有所帮助。

我使用的是Ubuntu bionic 18.04.4 LTS和tmux 2.6。 我也有同样的问题,它可以通过简单地将此添加到.bashrc来解决

export TERM=screen-256color

当然,别忘了注明出处。 源~ / . bashrc

或者重启你的终端机

我需要vim在ubuntu的终端上使用tmux正确显示,在windows上使用cygwin/mintty。我把答案像这样组合起来。

打印.bashrc:

alias tmux="tmux -2"

在. 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

基于这个问题的答案,这个Vim wiki页面和这个块游标问题

正如上面提到的@romainl,我需要通过添加-2标志来强制tmux使用256种颜色:

$ tmux -2

我添加了别名tmux='tmux -2'到我的bash_profile,所以,我不会忘记:)

在我的.tmux.conf中,我并没有尝试导出一个不同的TERM或设置默认终端。

我在tmux中修复vim颜色的解决方案是在.tmux.conf中添加这一行:

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

我不确定为什么需要这种重写,因为我的TERM=xterm,我也将iTerm设置为xterm,但它似乎是有效的。