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.
solarized.vim
and I was all set.