I installed Ubuntu 11.10. Then downloaded Solarized theme for Gnome Terminal. From terminal my vim looks good: plugin vim-powerline displays correctly and syntax is highlighted with proper colors. But when I run tmux and there run vim - syntax highlight uses only one basic color and vim-powerline displays no colors. I looked at the FAQ on vim-powerline and solution should be this line in .tmux-config:
set -g default-terminal "screen-256color"
But it doesn't work. I looked at TERM and it's return 'xterm' so I tried:
set -g default-terminal "xterm-256color"
But this also dosen't help.
This is the only line in .tmux.config. In .vimrc I have following lines:
call pathogen#infect()
set nocompatible
set encoding=utf-8
set laststatus=2
let g:Powerline_symbols = 'fancy'
set t_Co=256
syntax enable
set background=dark
colorsheme solarized
Starting tmux with the following flag fixes this for me:
from tmux man page:
-2 Force tmux to assume the terminal supports 256 colours.
this worked for me
in
.tmux.conf
in
.vimrc
remove old term value for .vimrc, believe me this will work
I am having the same problem on Ubuntu 10.04 LTS using Byobu 5.17 & tmux 1.5 using the latest Solarized from the GitHub repo.
I was able to partially fix this by specifying
$TERM
in the.bashrc
file:export TERM="xterm-256color"
It seems, also, that there is a bug filed on launchpad, but it is not yet resolved: byobu not displaying dircolors properly
Terminal type should be set to screen-256color in ~/.tmux.conf. It tells tmux what to set the TERM evironment variable, so it won't work for the current session - start a new one and test then.
If it still doesn't work, you can run Vim using:
This sets the environment variable just for a one-off vi execution.
If that doesn't make vim display all the colours, test if your terminal (I'm not sure if you're testing with just one terminal emulator) is compiled to support the 256 colour palette - download and run the below Perl script from the terminal emulator in question.
http://scie.nti.st/dist/256colors2.pl
PS. I assume you've already corrected the typo jordanbrock noticed.
To me it looks like nobody knows what is talking about...
How does our opening procedure works:
tmux
vim
/nvim
1 Terminal
Open a terminal (whichever you use - I use
st
) and write a command:As answer I got a string
st-256color
because this string is compiled as the C string literaltermname
in thest
(check here). It is similar with whichever terminal you use. Somewhere in the binary there is a string literal that is set as a enviromental variableTERM
when terminal is started.Here you can't do anything but to remember this string.
2 Tmux
Now lets continue the chain...
tmux
is opened after your terminal. In configuration file~/.tmux.conf
I must now first make sure to identify enviromental variableTERM
that my terminal set. So I write like this:This line checks if enviromental variable
$TERM
starts withst
(thereforest*
) and makes sure to use true color because current "indexed colors" (8 bits = 2^8 = 256 colors) is not enough for us. We wanttmux
to use "true colors" (24 bits = 2^24 = 16777215 colors). Here we could add some more lines just to be sure we will match the value ofTERM
. In my case the below line also works because it searches for256col
in the middle ofTERM
:And if I would use
xfce4-terminal
that setsTERM = xterm-256color
I could use a line like this instead:So far
tmux
is covered. But before we continue the chain, we must make sure thattmux
as well will export it's enviromental variableTERM
.In this case we can set it to whatever we want using this line inside the
~/.tmux.config
:Now make sure to exit the
tmux
and kill it's server:Then enter
tmux
by using commandtmux
and execute command:You should get answer
tmux-256color
. Now we can continue tovim
...3 Vim
In our final step we just have to configure
vim
by adding this line inside it's configuration file~/.vimrc
:This properly sets escape sequences
&t_8f
and&t_8b
and finally sets "true colors" insidevim
. But this is done only ifTERM
value is:st-256color
(when if I openvim
directly in thest
terminal without openingtmux
prior to that)tmux-256color
(when I openvim
while already intmux
)If you are using multiple terminals, here you should add them like this:
Otherwise colors will not work across all the terminals... Good luck!
As explained by Marcin Kaminski, if
TERM=screen-256color vim <filename>
works for you then just add following to your.bashrc
and following in your
.tmux.conf
:I had the same problemd, this works for me.
There's a typo in the last line of your
.vimrc
.It should be
colorscheme solarized
Not sure if that helps :)
You may be having the same problem documented in this answer.
Basically, .tmux.conf setting works, and
TERM
is set toscreen-256color
, but then tmux opens bash and calls your .bashrc, which setsTERM
to something else (perhapsxterm-256color
).The solution is to set
TERM
in your terminal settings rather than in .bashrc. If that's not an option, you can checkTERM
inside .bashrc and not change it if it's alreadyscreen-256color
.In the shell starting tmux, check that
$TERM
is eitherxterm-256color
orscreen-256color
. See how to change $TERM:~/.Xresources
is the best way (if supported)As an alternative, as Holy Mackerel said, you can force tmux to 256color via:
[Solucion][1] that may disturb your vision and make Vim unpleasant to use for an extended period of time.
You can fix this by running :set term=screen-256color in Vim or by relaunching Vim under the TERM=screen-256color environment, as some experts recommend: http://sunaku.github.io/vim-256color-bce.html