1

The terminal i'm using is termite, and it is very good, but i'm having a problem with vim colorschemes and some colors in the terminal itself too when using tmux. It happens as follows: Right = no tmux; Left = tmux As you can see in the screenshot, when i open nvim or vim with tmux, the case on the left, the colorscheme gets altered, this happens with all colorschemes i tested (about 15 or 20). I observed, that when i execute the command TERM=xterm-256color tmux right after i enter termite, the nvim/vim (i simlinked my .vimrc, so it is the same as init.vim) colorschemes works like a charm! I'm using i3-gaps, so, i decided to set the binding, $mod+Return to open termite that way:

  • bindsym $mod+Return exec termite -e 'TERM=xterm-256color tmux'

It should have worked, but when i press the keys, the screen only blinks and nothing happens.

Things i've tried include:

  • Set $TERM to various values, both in termite, in ~/.tmux.conf.local and in my .vimrc: xterm-256color, screen-256color, termite-256color;

  • Tested the same thing with other terminal emulators, like xfce-terminal and gnome-terminal, in both it works normally, and the colors get displayed correctly;

  • Set in my .vimrc:

    `if &term == "screen"` 
    
        `set t_Co=256`
    
    `endif`
    
  • Starting tmux with tmux -2;

  • Aliasing in my .zshrc:

    tmux="tmux -2";
    
    tmux="TERM=xterm-256color tmux" (screen blinks and nothing happens);
    
    termite="termite --exec "TERM=xterm-256color tmux";
    
    termite="termite -e "TERM=xterm-256color tmux".
    

Edit: The $TERM inside and outside tmux continue to be the same as the terminal. It outputs the same thing when I echo $TERM inside and outside tmux. This happened with termite, have to test it with other terminals.

2
  • What's the TERM value set to in tmux? you may need to specify to tmux that it's using a 256 color capable terminal, as well as letting termite know. Oct 17, 2018 at 12:10
  • The TERM in tmux is screen-256color. I read in the FAQ, that is not recommend to set it to anything else, I tried, anyway, to set it to other values, with no success. Oct 17, 2018 at 13:35

3 Answers 3

3

For the ones with a similar problem or the same one here it goes: you just need to set the $TERM variable to be the same in your .rc and in .tmux.conf files. To know if something is wrong, i recommend using :checkhealth command inside neovim.

1

I'm using these configurations in my ~/.tmux.conf file, should works with you also:

set -g terminal-overrides ',xterm-256color:Tc'
set -g default-terminal "tmux-256color"
set -as terminal-overrides ',xterm*:sitm=\E[3m'
2
  • I tested it now, it doesn't worked... :( Oct 17, 2018 at 22:34
  • This worked for me, was almost giving up.
    – fmilani
    Jun 22, 2022 at 3:20
1

So, if anyone is still interested in finding a fix; for those who still have the same problem: I was able to get it working nicely without doing much.

I had forgotten about this matter and stopped using tmux for a long time until I decided to ask about it on a Linux group on Telegram and a cool lad helped me with the issue. We've come up to this, on the sxhkd config file:

# Open alacritty with tmux
super + shift + Return
    alacritty -e $SHELL -i -c tmux &

I changed terminal to Allacrity, that's a GPU-based term, faster and more easily configurable out-of-the-box, but i don't think that has something to do with, to be fair. Honestly, i don't remember having had the issue with the colors on Alacritty, because, at the time, i didn't used it as it was in beta or something...

You can both add that to a key-binding in your wm's rc, or create an alias for that in your shell rc.

Also, as stated before:

you need to set the $TERM variable to be the same in your .rc and in .tmux.conf files. To know if something is wrong, i recommend using :checkhealth command inside neovim.

Colors now behave the same in and out of tmux :)

The file for the sxhkd configuration is on my GitHub, line 06.

I know that necroposting isn't good, but I had to do it as this problem had haunted me for several months, and it was very hard to find a sulution even though i searched in the web on a variety of forums and FAQs, read the docs about the software in question and couldn't find something relevant.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .