3

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:

enter image description here

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:

enter image description here

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

enter image description here

Without tmux:

~$ echo $TERM
xterm

enter image description here

  • 1
    What's the value of $TERM inside tmux? It should be screen-256color. – Ingo Karkat May 6 '15 at 14:15
  • I added answer to original question edit. My tmux does have the set-option -g default-terminal "screen-256color" why is it screen? – user1135541 May 6 '15 at 14:29
4

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.

4

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).

  • Thank you, this is the problem, changing to screen-256color is a different question that I will ask. – user1135541 May 6 '15 at 15:07
2

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.

  • Thanks, also I did find a solution, just upgrade TMUX, can be seen here: stackoverflow.com/questions/25940944/… – user1135541 May 26 '15 at 15:54
  • 1
    this 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 – chugadie Jan 4 '16 at 14:29
2

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:

  1. Upgrade tmux to 2.0 version. (To see what your current version is use: tmux -V)

  2. Add terminal support for 256 color mode (~/.bashrc):

    export TERM="screen-256color"
    alias tmux="tmux -2"
    
  3. Tell tmux what terminal type should be used (~/.tmux.conf):

    set -g default-terminal "screen-256color"
    
  4. 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.

0

Vim

~/.vimrc:

set t_Co=256
colorscheme <name>

Tmux

~/.tmux.conf:

set -g default-terminal "screen-256color"

Shell

After the previous changes, you should adapt your workflow to one of these options:

Option #1: always start tmux with the -2 argument:

tmux -2

Option #2: set up an alias in your shell config file (~/.bashrc, ~/.zshrc):

alias tmux="tmux -2"

Option #3: create a tmux script in /usr/local/bin/tmux and make sure /usr/local/bin/ comes before /usr/bin in your $PATH:

#!/bin/sh
/usr/bin/tmux -2 "$@"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.