airline.vim does not work inside tmux - vim

I am new to tmux and also not an expert on VIM, I tried to use tmux these days, but seems that airline disappeared when I used vim inside tmux. I would like to show you the screen shots and hopefully anyone can help me solve this problem.
airline in vim
airline inside tmux

You need to correctly set $TERM environment variable to make vim properly detect 256 colors support by doing the following before opening vim:
export TERM=screen-256color

While the accepted answer works, it is not cheap. Manually setting the value of the $TERM variable will usually be set correctly by itself.
It is usually a good a idea to force tmux to assume the terminal supports 256 colors.
In your ~/.bash_aliases, add:
tmux='tmux -2'
Answer based on the following posts:
What is the difference between screen-256 color and xterm-256color
tmux vim colorscheme background is not showing

Add the following line in your .tmux.conf
set -g default-terminal screen-256color

In my case, using ubuntu 20.04 inside windows with WSL2, the accepted answer (export TERM=screen-256color), just freeze the tmux pane.
The fix for me was add to ~/.vim/vimrc:
set t_Co=256

Related

Color issues with vim in tmux over ssh.

I am having an issue with tmux and vim where the background colors differ, but only when I am ssh'd into another machine. No solutions for posted questions I've found so far have worked for me.
On the left is my local machine, the right is when I'm ssh'd into my devbox. This is one tmux session.
On both machines:
TERM is set to "screen-256color"
using bash
.vimrc contains set term=screen-256color
.tmux.conf contains set -g default-terminal "screen-256color"
I'm using Gnome. The background color in tmux when I'm in ssh and just using the cli is normal, this only occurs when I open vim and it returns to the normal color scheme when I exit.
I was able to resolve this by using colo default in my .vimrc. I was tunnel visioned convinced it was a tmux issue, and completely forgot vim was sourcing a system .vimrc on the remote box.

Tmux does not show Vim colors properly (Ubuntu 14.04)

Searching around, I found that it might be a problem with Tmux detecting the correct terminal mode, so I placed this in my .tmux.conf:
set -g default-terminal "screen-256color"
Together with alias tmux="tmux -2" it makes some colorschemes work (badwolf for example), but not all of them (doesn't work for solarized, vividchalk and base16 for example). Since I wanted at least solarized, I installed it to gnome-terminal and to Vim. Colors show properly out of Tmux, but not in Tmux. I also set t_Co=256 (in Vim) but without success.
According to Tmux faq, there is nothing wrong with my configuration, but yet I can't get it to display properly. Any idea?
Update
To give a better understanding of the problem, below are some images.
First, Gvim (left) and Vim (right, in gnome-terminal):
Second, Vim (left, in gnome-terminal), Vim with tmux (right, also in gnome-terminal):
Credits: the code is from Princeton Algorithms course (authors: Robert Sedgewick and Kevin Wayne).
There are some steps required to solve this problem:
Install the solarized theme for gnome-terminal, found here.
Install the solarized theme for Vim (found here).
Create an alias for the tmux command or set the TERM variable as mentioned in ianks answer (in your .bashrc):
alias tmux="TERM=screen-256color-bce tmux"
Include the following line in your .tmux.conf:
set -g default-terminal "screen-256color"
I needed all these 4 steps to make my terminal colors show solarized. This post provides some other alternatives in case this doesn't work. One particular comment in that post helped the most, pointing to this resource.
It turns out that without setting the TERM variable, if you echo $TERM you see exactly what Tmux FAQ said you should (screen-256color), but you don't get the correct colors, don't know why.
Have you tried adding this to your .(*)shrc?
export TERM=screen-256color-bce
Back when I used gnome terminal this worked for me, but don't ask me why :)

Vim line number setting not showing when using tmux

When I use vim (set number) in the .vimrc file, it works fine in the terminal, but when using tmux the line numbers just don't show.
You have to set the same $TERM for your shell and tmux. Otherwise this will cause all kinds of trouble, especially when used in connection with powerline (or vim in your case).
See: https://wiki.archlinux.org/index.php/tmux#Setting_the_correct_term
As answered by three, you have to actually set the correct $TERM for BOTH your shell and TMUX
I also had a similar problem like yours today and got it working with the following steps.
To know your current $TERM in your shell, you can use the command:
echo $TERM
for me, I got the output xterm-256color.
Then in your ~/.tmux.conf file, you can set the tmux to use xterm-256color by adding this to the file.
set -g default-terminal "xterm-256color"
and all should work fine. :)
Hope I've helped.

Configuring solarized colorscheme in gnome terminal, tmux and vim

I'm struggling to make the Solarized colorscheme correctly working on an Ubuntu 13.10 machine inside Vim inside tmux inside the gnome-terminal.
I've started configuring gnome-terminal using the script on this repository and it displays the colors correctly. The same goes if I run Vim (with the official Solarized colorscheme) inside the terminal, without tmux.
Then I tried to configure tmux using this. It happens that when I run Vim the syntax highlight for php or javascript code is wrong or, at least, different from the one I see running Vim without tmux. I've tried also running tmux as tmux -2. The colors are different, but still the syntax highlight is not correct.
I tested it out and got it working in the following way:
Install gnome solarized colorscheme. You can get it from https://github.com/aruhier/gnome-terminal-colors-solarized.
Install solarized colorscheme for vim. You can get it from https://github.com/altercation/vim-colors-solarized. In .vimrc you should add following settings:
set t_Co=256
set background=dark
colorscheme solarized
Set correct TERM variable by adding following line to your .bashrc/.zshrc
export TERM=screen-256color-bce
Run gnome-terminal, tmux, vim and profit.
These days GNOME Terminal comes with Solarized colours built in. To use it, you need to change two settings in the profile that you're using. The obvious one is the text and background colour. You also need to set the palette to Solarized, though. You can find this setting below the one for the text and background colour. At this point, setting t_Co or g:solarized_termcolors in Vim shouldn't be necessary.
The palette is the part that I missed at first, which caused me to puzzle why the text in Vim and other applications was bright blue.

Setting VIM for 256 colors

I've googled it for hours but I can't find a solution.
I use raspian, on a raspberry pi and I want to have colorscheems work on it.
Default terminal in raspian seems to be set at 8 colors as when I enter
tput colors
I get 8.
I'm sure there must be a way to have the term work with 256 colors but I don't know how. Anyway I set tmux in the config file to support 256 colors, so I created a .tmux.conf file in my home directory and have
set -g default-terminal "screen-256color"
now if I check with tput within tmux I get 256.
Anyway I know you can set VIM to force think you support 256 color by adding
set t_Co=256
but this seems to make no actual change.
If I run this color test
:runtime syntax/colortest.vim
in normal terminal from raspian I get only 8 different colors. If I do this on tmux I get more but not all of them because some of them (red and lightred for example) still look the same.
did you add set t_Co=256 after the line colorscheme <yourColourScheme>? That was a problem I had early on.
Let me know if you're still having trouble, because I managed to solve a similar problem (only I'm using MobaXterm and GNU screen), and wouldn't mind the excuse to dig into this a bit more.
I was having a similar problem and have solved it with the following setup. .zshrc on my OSX laptop contains:
TERM=xterm-256color
after I ssh into raspbian, tput colors returns 256. On raspbian, I don't have TERM explicitly set (which means it pulls it from ssh), and have the following in .tmux.conf:
set -g default-terminal "xterm-256color"
Then after I do tmux (and I don't even need the -2), tputs colors still reports 256 colors and vim looks right. I am using vanilla solarized with no edits in .vimrc or elsewhere in the vim configs.

Resources