Terminal colors for Vim Airline and Tmux Tmuxline

7,615

You can use tmux -2 to solve this issue.

Share:
7,615
Naftuli Kay
Author by

Naftuli Kay

Updated on September 18, 2022

Comments

  • Naftuli Kay
    Naftuli Kay almost 2 years

    When using Vim on its own with Vundle and Airline the theme appears normally:

    enter image description here

    When I have loaded it up in Tmuxline, the theme uses different colors and even Vim looks different:

    enter image description here

    enter image description here

    Here's my Tmux configuration:

    set -g default-terminal "screen-256color"
    
    source-file /home/tk/.tmux/tmuxline
    
    unbind C-b
    
    set -g prefix C-o
    
    bind | split-window -h
    bind - split-window -v
    
    set-window-option -g mode-keys vi
    
    bind-key -t vi-copy 'v' begin-selection
    bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'
    
    bind C-y run "tmux save-buffer - | xclip -selection clipboard"
    

    Here's my Vim configuration:

    set nocompatible " be iMproved, required
    filetype off     " required
    
    " set the runtime path to include Vundle and initialize
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    " alternatively, pass a path where Vundle should install plugins
    "call vundle#begin("~/some/other/path")
    
    " let Vundle manage Vundle, required
    Plugin 'gmarik/Vundle.vim'
    
    Plugin 'Valloric/YouCompleteMe'
    Plugin 'scrooloose/syntastic'
    Plugin 'bling/vim-airline'
    
    Plugin 'godlygeek/tabular'
    Plugin 'plasticboy/vim-markdown'
    
    Bundle 'edkolev/tmuxline.vim'
    
    " include plugins here
    
    call vundle#end()
    filetype plugin indent on
    
    set backspace=indent,eol,start
    
    set showcmd
    set incsearch
    set number
    set expandtab
    set tabstop=4
    set shiftwidth=4
    set hlsearch
    set ic
    set autoindent
    set cmdheight=1
    set laststatus=2
    
    syntax enable
    
    set nobackup
    set noswapfile
    set showmatch
    
    " airline
    let g:airline_powerline_fonts = 1
    let g:airline_theme = 'kolor'
    
    set t_Co=256
    

    Obviously, my colors are screwed up somewhere along the line. How do I fix this?

    • Admin
      Admin almost 10 years
      Your issue makes me think of this one i.e. the interplay between terminal settings and tmux.
    • slm
      slm almost 10 years
      Does tmux change the $TERM env. variable?
    • Egel
      Egel about 9 years
      Did you resolve this issue?
  • X Tian
    X Tian almost 9 years
    Could you add to your answer, an explaination why the tmux config line `set -g default-terminal "screen-256color"`` doesn't do the same as your answer, thank you.