I've googled it for hours but I can't find a solution.
I use raspian, on a raspberry pi and I want to have colorscheems work on it.
Default terminal in raspian seems to be set at 8 colors as when I enter
tput colors
I get 8.
I'm sure there must be a way to have the term work with 256 colors but I don't know how. Anyway I set tmux in the config file to support 256 colors, so I created a .tmux.conf file in my home directory and have
set -g default-terminal "screen-256color"
now if I check with tput within tmux I get 256.
Anyway I know you can set VIM to force think you support 256 color by adding
set t_Co=256
but this seems to make no actual change.
If I run this color test
:runtime syntax/colortest.vim
in normal terminal from raspian I get only 8 different colors. If I do this on tmux I get more but not all of them because some of them (red and lightred for example) still look the same.
did you add set t_Co=256 after the line colorscheme <yourColourScheme>? That was a problem I had early on.
Let me know if you're still having trouble, because I managed to solve a similar problem (only I'm using MobaXterm and GNU screen), and wouldn't mind the excuse to dig into this a bit more.
I was having a similar problem and have solved it with the following setup. .zshrc on my OSX laptop contains:
TERM=xterm-256color
after I ssh into raspbian, tput colors returns 256. On raspbian, I don't have TERM explicitly set (which means it pulls it from ssh), and have the following in .tmux.conf:
set -g default-terminal "xterm-256color"
Then after I do tmux (and I don't even need the -2), tputs colors still reports 256 colors and vim looks right. I am using vanilla solarized with no edits in .vimrc or elsewhere in the vim configs.
Related
I am new to tmux and also not an expert on VIM, I tried to use tmux these days, but seems that airline disappeared when I used vim inside tmux. I would like to show you the screen shots and hopefully anyone can help me solve this problem.
airline in vim
airline inside tmux
You need to correctly set $TERM environment variable to make vim properly detect 256 colors support by doing the following before opening vim:
export TERM=screen-256color
While the accepted answer works, it is not cheap. Manually setting the value of the $TERM variable will usually be set correctly by itself.
It is usually a good a idea to force tmux to assume the terminal supports 256 colors.
In your ~/.bash_aliases, add:
tmux='tmux -2'
Answer based on the following posts:
What is the difference between screen-256 color and xterm-256color
tmux vim colorscheme background is not showing
Add the following line in your .tmux.conf
set -g default-terminal screen-256color
In my case, using ubuntu 20.04 inside windows with WSL2, the accepted answer (export TERM=screen-256color), just freeze the tmux pane.
The fix for me was add to ~/.vim/vimrc:
set t_Co=256
I have OSX Yosemite with iTerm2. I connect via ssh to my virtual machine with Debian 8. When I run vim all colors are messed up.
iTerm2 has xterm-256colors on.
A number of things can affect your Vim colorscheme.
Make sure iTerm has the terminal type correct. As you indicated already, you use xterm-256color.
Make sure your remote shell has a matching terminal type, which you can verify with echo $TERM. If it is not set already, configure your shell with something like
# For sh, bash, zsh, ksh
export TERM=xterm-256color
# For csh, tcsh
setenv TERM xterm-256color
If the color scheme you are trying to use assumes that 256-color support is available, you may also need to add to your .vimrc:
set t_Co=256
Lastly, color schemes can be affected by the background setting in Vim, which you can set to either dark or light. To see what it's set to,
:set background?
And to set it one way or the other in your .vimrc,
set background=dark
(or light).
Searching around, I found that it might be a problem with Tmux detecting the correct terminal mode, so I placed this in my .tmux.conf:
set -g default-terminal "screen-256color"
Together with alias tmux="tmux -2" it makes some colorschemes work (badwolf for example), but not all of them (doesn't work for solarized, vividchalk and base16 for example). Since I wanted at least solarized, I installed it to gnome-terminal and to Vim. Colors show properly out of Tmux, but not in Tmux. I also set t_Co=256 (in Vim) but without success.
According to Tmux faq, there is nothing wrong with my configuration, but yet I can't get it to display properly. Any idea?
Update
To give a better understanding of the problem, below are some images.
First, Gvim (left) and Vim (right, in gnome-terminal):
Second, Vim (left, in gnome-terminal), Vim with tmux (right, also in gnome-terminal):
Credits: the code is from Princeton Algorithms course (authors: Robert Sedgewick and Kevin Wayne).
There are some steps required to solve this problem:
Install the solarized theme for gnome-terminal, found here.
Install the solarized theme for Vim (found here).
Create an alias for the tmux command or set the TERM variable as mentioned in ianks answer (in your .bashrc):
alias tmux="TERM=screen-256color-bce tmux"
Include the following line in your .tmux.conf:
set -g default-terminal "screen-256color"
I needed all these 4 steps to make my terminal colors show solarized. This post provides some other alternatives in case this doesn't work. One particular comment in that post helped the most, pointing to this resource.
It turns out that without setting the TERM variable, if you echo $TERM you see exactly what Tmux FAQ said you should (screen-256color), but you don't get the correct colors, don't know why.
Have you tried adding this to your .(*)shrc?
export TERM=screen-256color-bce
Back when I used gnome terminal this worked for me, but don't ask me why :)
I'm struggling to make the Solarized colorscheme correctly working on an Ubuntu 13.10 machine inside Vim inside tmux inside the gnome-terminal.
I've started configuring gnome-terminal using the script on this repository and it displays the colors correctly. The same goes if I run Vim (with the official Solarized colorscheme) inside the terminal, without tmux.
Then I tried to configure tmux using this. It happens that when I run Vim the syntax highlight for php or javascript code is wrong or, at least, different from the one I see running Vim without tmux. I've tried also running tmux as tmux -2. The colors are different, but still the syntax highlight is not correct.
I tested it out and got it working in the following way:
Install gnome solarized colorscheme. You can get it from https://github.com/aruhier/gnome-terminal-colors-solarized.
Install solarized colorscheme for vim. You can get it from https://github.com/altercation/vim-colors-solarized. In .vimrc you should add following settings:
set t_Co=256
set background=dark
colorscheme solarized
Set correct TERM variable by adding following line to your .bashrc/.zshrc
export TERM=screen-256color-bce
Run gnome-terminal, tmux, vim and profit.
These days GNOME Terminal comes with Solarized colours built in. To use it, you need to change two settings in the profile that you're using. The obvious one is the text and background colour. You also need to set the palette to Solarized, though. You can find this setting below the one for the text and background colour. At this point, setting t_Co or g:solarized_termcolors in Vim shouldn't be necessary.
The palette is the part that I missed at first, which caused me to puzzle why the text in Vim and other applications was bright blue.
I'm trying to use the light solarized theme with vim and xfce4-terminal.
I installed the theme for xfce4-terminal:
cd
mkdir solarized ; cd solarized
git clone https://github.com/sgerrand/xfce4-terminal-colors-solarized.git
cp xfce4-terminal-colors-solarized/light/terminalrc ~/.config/xfce4/terminal/
Apparently it works fine. However, when I use vim, the colors are different from the expected:
Gvim presents the correct colors. Konsole (with the proper theme, from the same git repository) shows the correct colors too.
The dark theme is presented correctly if change the vim and the xfce4-terminal theme.
I tried to change TERM and t_Co, but it didn't work.
I tried to follow this answer but it remains with the incorrect colors.
The link above says that the xfce4-terminal devs have changed the syntax of terminalrc.
When I compare xfce4-terminal and konsole pallets, I see that the there are some colors different, so I think terminal isn't reading rightly the terminalrc archive. Since the terminalrc archive from git is 2 years old, it makes sense. However, I don't know how to modify to the correct colors since I don't know the correspondence between the pallets of Konsoleand Xfce.
Does anyone have a suitable archive? Does anyone want to create one and make it available via git, updating the config for other people? (presuming that it's in fact a problem with the recent syntax.)
oK got it work!
You cannot use the colors which are on git hub xfce4-terminal
For the dark you can use the one which comes with xfce-terminal (Edit->Properties->Color->Presets * Solarized (dark/light)
Important is that you go afterwards to ~/.config/xfce4/terminal/terminalrc and remove
ColorCursor=
Than edit the .vimrc with
syntax enable
set background=dark
colorscheme solarized
set t_Co=16
set background=dark works for me with light and dark terminal setting.
I have exactly the same problem.
I get the best results with this.
It is not 100% the same but looks best to me
let g:solarized_termcolors=256
syntax enable
set background=light
colorscheme solarized
set t_Co=256
Hope that helps