我正在运行iterm2,当我在tmux模式下,我在vim中设置的配色方案不显示。只有我设定的配色方案。如果我从shell运行vim,配色方案显示正确-只有当我在tmux模式。
我尝试过在vim中设置:colorscheme molokai(见下面的截图),它没有改变-再次,iterm2的默认配色方案保持不变。
我是否遗漏了对iterm或tmux.conf的一些设置?我的图都在github上。
我正在运行iterm2,当我在tmux模式下,我在vim中设置的配色方案不显示。只有我设定的配色方案。如果我从shell运行vim,配色方案显示正确-只有当我在tmux模式。
我尝试过在vim中设置:colorscheme molokai(见下面的截图),它没有改变-再次,iterm2的默认配色方案保持不变。
我是否遗漏了对iterm或tmux.conf的一些设置?我的图都在github上。
当前回答
我也有同样的问题。唯一不同的是我使用的是太阳能而不是莫洛凯。
为了解决这个问题,我在~/.bashrc中设置了一个别名:
alias tmux="TERM=screen-256color-bce tmux"
在~/.tmux.conf中设置default-terminal选项:
set -g default-terminal "xterm"
最后,执行$ source ~/。Bashrc加载新别名。
其他回答
我使用的是Ubuntu bionic 18.04.4 LTS和tmux 2.6。 我也有同样的问题,它可以通过简单地将此添加到.bashrc来解决
export TERM=screen-256color
当然,别忘了注明出处。 源~ / . bashrc
或者重启你的终端机
如果有人需要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中添加任何其他内容。
希望这能有所帮助。
在我的.tmux.conf中使用这两行对我来说是有效的,我使用的是带有Alacritty的Ubuntu 20.04。
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",alacritty:RGB"
在一篇关于alacitty回购的文章中找到了它们,在YodaEmbedding提供的评论中:
https://github.com/alacritty/alacritty/issues/109
I just discovered why I was having a lot of confusion. I, like others here, was having a difficult time getting the default-terminal setting to take effect. I remembered that I had a tmux session in the background. I re-attached my session, closed out my processes, and closed ALL tmux processes. The next time I restarted tmux the default-terminal setting in .tmux.conf began to take effect. I don't know if others are doing this as well but I recommend closing all tmux processes before modifying the .tmux.conf file.
我让我的设置在我的本地机器上工作(OSX 10.9.5 with iTerm2),没有对.bashrc或.bash_profile进行任何修改。我所做的只是将行set -g default-terminal "xterm-256color"添加到~/.tmux.conf并重新启动所有tmux进程。
我让我的远程设置(ssh到Ubuntu 14.04)以完全相同的方式工作,而不需要对.bashrc进行任何修改。我只是在远程机器上的~/.tmux.conf中添加了set -g default-terminal "xterm-256color",并重新启动了所有远程tmux进程。
你可以在tmux会话中通过echo $TERM来测试Vim所看到的内容。它一直将screen作为值,直到我重新启动所有tmux进程,此时它如预期的那样反射xterm-256color。
希望这能有所帮助。
在我的.tmux.conf中,我并没有尝试导出一个不同的TERM或设置默认终端。
我在tmux中修复vim颜色的解决方案是在.tmux.conf中添加这一行:
set -g terminal-overrides 'xterm:colors=88'
我不确定为什么需要这种重写,因为我的TERM=xterm,我也将iTerm设置为xterm,但它似乎是有效的。