Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

There's a lot of questions around this, but it's because there are so many variables. I had to piece together instructions from many sites before I got this working.

First, I could not easily set up the 16 solarized colour definitions in gnome-terminal (I did it by hand/clicking only to realise that I'd not got the order/mapping correct). Once I fixed that I moved on...

Then I had solarized colours working in vim OK-ish, but there was some odd black backgrounds appearing in certain highlighting. Once I fixed that, I moved on...

Then I realised vim went v. wonky once running inside tmux. This is massively debated, but very few of the answers (which mostly say about setting TERM to xterm-256colors) worked for me. I eventually fixed that too.

Solarized is a very nice palette (although I darkened the darkest base colour and lightened the lightest as I prefer the higher contrast and found tmux's 'white' far far too yellow on my calibrated screen - prob fine on a typical uncalibrated laptop screen as they're usually way too blue!), so I'm posting this question with its answer to share the results of my learning.

share|improve this question
    
I use xterm-256color (not GNOME terminal), tmux, and vim and don't remember having to jump through anywhere near this many hoops. The only thing I had to do was solarize the terminal (xterm uses XResources instead of profiles) which was a slight pain to figure out, add solarized.vim and I was all set. –  jw013 Mar 1 '13 at 18:33
    
Thanks for the public write-up. –  Jonathan Hartley Jul 9 '13 at 14:44
    

2 Answers 2

up vote 15 down vote accepted

Solarized gives very specific colours. You can't really achieve these colours in a standard 256 colour palette. The only way you can achieve this is through setting up the exact colours in your terminal emulator, then apps think they're just using standard 16 colours (8 + 8 brights) but these have been accurately mapped to the Solarized palette.

Gnome terminal does not provide a very easy way to export/import palettes or profiles, but you can do it with this bash script:

#!/bin/sh
DARK_BG='#000014141A1A'
# original: DARK_BG='#00002B2B3636'
LIGHTEST='#FFFFFBFBF0F0'
# original: LIGHTEST='#FDFDF6F6E3E3'

gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:$DARK_BG:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:$LIGHTEST"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "$DARK_BG"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#65657B7B8383"

Nb. here I've overridden Solarized's darkest and lightest colours. You can use the originals if you like, as commented.

Good enough. Now install the Solarized vim colours file by placing that file in ~.vim/colors/solarized.vim.

Now you can tell Vim to use that colour scheme with colo solarized. But this did not quite work and I had to tell Vim to use a 16 colour pallete, set t_Co=16. I stuck both of those in my ~/.vimrc file.

Now vim colours were working, but not if it ran inside tmux.

This next bit is very confusing. Most advice says about setting TERM outside tmux to xterm-256colors, but when I did that tmux would not even start. It confused me, too: doesn't solarized say that the 256 colour palette is a poor approximation? Well, it is confusing, and anyway, it wasn't working so I needed another way forward:

Create a file /tmp/foo containing:

xterm-16color|xterm with 16 colors,
    colors#16, use=xterm,

Then install this with sudo tic /tmp/foo

Finally, alias tmux as follows:

alias tmux='TERMINFO=/usr/share/terminfo/x/xterm-16color TERM=xterm-16color tmux -2'

I now get exactly the right colours in the terminal, in vim, and in vim-inside-tmux. Nb. the -2 option tells tmux to use a 256 colour palette, which is really confusing because the env variables would appear to be telling it otherwise... I genuinely don't know, and I'm afraid I don't really care to climb that learning curve because I now have a beautiful coloured terminal that Just Works.

share|improve this answer
    
set t_Co=16 did the trick for me. Before setting that option syntax hightlighting did not work at all. –  Koraktor Jun 10 at 7:36

I also found this project:

https://github.com/sigurdga/gnome-terminal-colors-solarized

Thanks for the tips :-)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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