Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim colors not showing in tmux

Tags:

vi

tmux

I have not been able to use vim in tmux for about a week now. I keep all of my dotfiles in Github (here https://github.com/jordanjones98/dotfiles) and when I got a computer I thought it would be an easy git pull, and some other simple setup. When I pulled, and installed my plugins everything works outside of tmux, but not inside. I am using vim 8.0 and tmux 2.6. I am using a zsh shell inside of iTerm.

It is worth noting that this same configuration worked on my old computer, and works on my current work computer. I even copied the iTerm configuration from my work computer to try and get this working.

A few things I have tried..
running tmux -2
running TERM=screen-256color-bce tmux
setting set -g default-terminal "screen-256color" in my .tmux.conf
setting "report terminal type" to xterm-256color in my iterm preferences.

I have also tried running it in regular mac terminal and once again vim runs fine outside of tmux, but not inside of tmux.

I have researched this for days now and have not found anything that works. I do know my .tmux.conf and .vimrc files are being loaded in tmux, because of the plugins, and bottom bar in my tmux.

My dotfiles are pretty large. So please view them here. https://github.com/jordanjones98/dotfiles

like image 897
Jordan Avatar asked Jan 29 '23 23:01

Jordan


1 Answers

I notice you don't set TERM in ~/.zshrc

Try this,

add

export TERM="screen-256color"

to .zshrc

instead of the bce entry - then make sure you source ~/.zshrc before starting a new tmux session

note. I am using osx so my tmux.conf uses set -g default-terminal "screen-256color", if you are on linux it may be different. the point is that this problem is often fixed with export TERM in my .zshrc.

edit

I tried your dot files and I think I reproduced the issue. The issue went away with this ugly workaround. Try adding the following to your ~/.vimrc file around line 44 before setting color scheme:

let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
like image 160
navicore Avatar answered Mar 21 '23 02:03

navicore