我正在运行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上。
当前回答
我使用gnome终端,这解决了问题,但(0)不要忘记:
killall tmux
(1)编辑.tmux.conf
# 24 bit color
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
(2)编辑:.vimrc
" Enable true color
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
rinetd发布的关于tmux回购问题的解决方案: https://github.com/tmux/tmux/issues/1246
其他回答
我需要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页面和这个块游标问题
假设你已经有了与终端相匹配的vim颜色:
运行tmux Kill -server终止所有tmux会话 在~/.tmux.conf中为tmux创建一个用户配置文件 在.tmux.conf文件中添加以下代码行: 设置-g default-terminal "tmux-256color" set -ga terminal-override ",xterm-termite:Tc" 在命令行中运行echo $TERM 用echo $TERM返回的输出替换xterm-termite
在我的.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
我尝试了上面所有的解决方案,最后对我有用的是在.tmux.conf中放入以下几行:
set -g default-terminal "xterm-256color"
如果有人需要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中添加任何其他内容。
希望这能有所帮助。