ENV:
Fedora 29 workstation x86_64, GNOME Terminal 3.30.1
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 8 2019 09:25:44)
GNU bash, version 4.4.23(1)-release (x86_64-redhat-linux-gnu)
tmux 2.7
vim is using solarized scheme.
.vimrc
...
let g:solarized_termcolors=256
let g:solarized_termtrans=1
syntax enable
set background=dark
colorscheme solarized
...
The value of $TERM
in bash is:
[u@loc ~]$ echo $TERM
xterm-256color
[u@loc ~]$ tput colors
256
Mehthod 1: works.
Check $TERM
value inside tmux session. Get
[u@loc ~]$ echo $TERM
screen
[u@loc ~]$ tput colors
8
So, just set export TERM=screen-256color
inside tmux session. This method only works in the current pane of the session.
Method 2: works.
Create ~/.tmux.conf
file and add set -g default-terminal "tmux-256color"
to the file.
or Just run echo "set -g default-terminal \"tmux-256color\"" > ~/.tmux.conf
Then kill all tmux sessions.
Start a new session and check the $TERM
value inside tmux session. Get
[u@loc ~]$ echo $TERM
tmux-256color
[u@loc ~]$ tput colors
256
And vim colorized scheme works fine for all pane and all tmux sessions.
I also tried xterm-256color
and screen-256color
in ~/.tmux.conf
. They all work fine for colorizing the vim scheme.
By the way, I don't have any configurations being related to this setting in my ~/.bash_profile
, ~/.bashrc
and ~/.vimrc
.
See also https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-a-256-colour-terminal, https://github.com/tmux/tmux/wiki/FAQ#why-do-you-use-the-screen-terminal-description-inside-tmux
Other useful talks are Vim color scheme changes in tmux #699, 256-color-support-for-vim-background-in-tmux, getting-256-colors-to-work-in-tmux, tmux-term-and-256-colours-support