VIM solarized color scheme looks wrong when using tmux
Solution 1
The value of $TERM
must be screen-256color
, so that Vim correctly detects the availability of 256 colors. (tmux
reuses the terminal definitions of screen
, as this tool implements similar multiplexing.)
You either need to set the correct value for TERM
inside tmux adding the line
set-option -g default-terminal "screen-256color"
to ~/.tmux.conf
, or force 256 colors in your ~/.vimrc
via set t_Co=256
(which would be a workaround, and best guarded by if $TERM == 'screen'
if you also use non-high color terminals).
Solution 2
The issue was the tmux version 1.8. I used advice from here:
https://stackoverflow.com/questions/25940944/ugrade-tmux-from-1-8-to-1-9-on-ubuntu-14-04
Upgraded tmux to version 1.9a, and the problem went away.
Solution 3
I had the same problem with tmux and vim using solarized theme. The problem was solved with the help of this blog post: http://www.terminally-incoherent.com/blog/2012/10/17/vim-solarized-and-tmux/
My steps to solve this problem were:
Upgrade tmux to 2.0 version. (To see what your current version is use:
tmux -V
)-
Add terminal support for 256 color mode (
~/.bashrc
):export TERM="screen-256color" alias tmux="tmux -2"
-
Tell tmux what terminal type should be used (
~/.tmux.conf
):set -g default-terminal "screen-256color"
-
Force vim to use 256 colors (
~/.vimrc
):set t_Co=256 " force vim to use 256 colors let g:solarized_termcolors=256 " use solarized 256 fallback
Restart terminal for changes to take effect.
Solution 4
Try tmux -2, the -2 means Force tmux to assume the terminal supports 256 colours. I created an alias so that tmux always starts that way.
Related videos on Youtube
![user1135541](https://i.stack.imgur.com/fkFuj.jpg?s=256&g=1)
user1135541
Updated on September 18, 2022Comments
-
user1135541 almost 2 years
I am trying to use the solarized color scheme in VIM using gnome terminal (Ubuntu). When I run vim without tmux, it looks great, see below:
If I add the following commands to my .bashrc
# tmux configuration tmux attach &> /dev/null if [[ ! $TERM =~ screen ]]; then exec tmux fi
and start the terminal with tmux, the colors do not look right, see below:
Here is the contents of the .tmux.conf file
source ~/.local/lib/python2.7/site-packages/powerline/bindings /tmux/powerline.conf set-option -g default-terminal "screen-256color" set-option -g history-limit 10000
I am using https://github.com/altercation/vim-colors-solarized for the vim color scheme, and the terminal is: https://github.com/Anthony25/gnome-terminal-colors-solarized.
EDIT: With tmux:
~$ echo $TERM screen
Without tmux:
~$ echo $TERM xterm
-
user1135541 about 9 yearsI added answer to original question edit. My tmux does have the
set-option -g default-terminal "screen-256color"
why is it screen?
-
-
user1135541 about 9 yearsThank you, this is the problem, changing to screen-256color is a different question that I will ask.
-
user1135541 about 9 yearsThanks, also I did find a solution, just upgrade TMUX, can be seen here: stackoverflow.com/questions/25940944/…
-
chugadie over 8 yearsthis was the only solution that worked on ubuntu 14.04. i tried: upgrading to tmux 2, and adding set-option terminal-256color to ~/.tmux.conf