You are not logged in.

#1 2013-05-27 17:56:15

drm00
Member
Registered: 2010-06-01
Posts: 38

Getting solarized colors right with urxvt, st, tmux and vim

Updates:

  • update to st revision 71328cbcdc88f4fdfbb62d8c0324938e245c8971

  • moved patches to the suckless st wiki page

  • urxvt now works, too.

Hi there!

For a long time, i tried to get the exact solarized colors in my terminal.  Unfortunately, most of the time, either the terminal was not presenting the colors right, or if so, they would break in vim or in vim inside tmux.  Now i got all of them right -- for urxvt, that is true at least for the current version shipped by arch linux.

Get solarized right with st, tmux and vim

The author of solarized strongly suggests to replace the 16 ANSI terminal colors with the solarized ones to get the right results, and thats exactly what we are going to do here.

Check if colors are right

To check for the right colors, i used the simpler-script and kcolorchooser to verify the colors manually.  No matter what terminal you use, make sure that the colors for normal and bold look the same:

WRGmVdp.png

urxvt

While i still can't get the right colors in urxvt on ubuntu 12.04, i now have a working configuration on Arch with rxvt-unicode 9.18.  To get it right, you need to add

URxvt.intensityStyles: false

to your ~/.Xresources, along with the solarized colors.

Configure st

I keep up with upstream for my patches (there is no change at all most of the time), but after a new stable release is out, i will only release patches for the stable releases.

$ mkdir ~/st-solarized
$ cd ~/st-solarized
$ git clone http://git.suckless.org/st
$ cd st
Patches

Patches are now at the st wiki.

Patch st.c to disable different colors for bold fonts
$ git apply st-no-bold-colors.diff
Create your config.h and adjust the solarized colors
$ cp config.def.h config.h
$ git add config.h

Before you configure your favorite font, fontsize etc. in config.h, apply one of these two patches to get the solarized colors in st:

For the dark variant of solarized:

$ git apply st-solarized-dark.diff

Or, if you like the light version more:

$ git apply st-solarized-light.diff

Note: If you are on openbsd, have a look at this patch as well.

Compile st and start it
$ make clean
$ make
$ sudo make install
$ st
Configure vim

Alright, the solarized colors show up nicely in st now.  But vim needs to be adjusted as well.

Install pathogen

See https://github.com/tpope/vim-pathogen:

$ mkdir -p ~/.vim/autoload ~/.vim/bundle
$ git clone https://github.com/tpope/vim-pathogen.git

and link the pathogen.vim to ~/.vim/autoload/pathogen.vim.

Get solarized vim colors

See https://github.com/altercation/solarize … -solarized:

$ cd ~/.vim/bundle
$ git clone git://github.com/altercation/vim-colors-solarized.git
Adjust your .vimrc

To use the right colors in vim, you need to enable pathogen and the solarized colors in your .vimrc:

set nocompatible                                           
set t_Co=16                                                
call pathogen#infect()                                     
syntax on                                                  
set background=dark " dark | light "                       
colorscheme solarized                                      
filetype plugin on

If you want to highlight the current line and column 80 as well, add

set cursorline
set colorcolumn=80

To toggle the color scheme between dark and light with F5, you can add

call togglebg#map("<F5>")

Now, vim should display the right colors as well.

Configure tmux
Adjust tmux colors

With standard settings, tmux uses colors for its decorations (status-bar, pane-indexes etc.) that do not match the solarized-look.  Here are the changes i made by adding this to my ~/.tmux.conf, feel free to adjust:

# --- colors (solarized dark)                                      
# default statusbar colors                                         
set -g status-bg black                                             
set -g status-fg yellow                                            
set -g status-attr default                                         
                                                                   
# default window title colors                                      
setw -g window-status-fg brightblue                                
setw -g window-status-bg default                                   
                                                                   
# active window title colors                                       
setw -g window-status-current-fg yellow                            
setw -g window-status-current-bg default                           
setw -g window-status-current-attr dim                             
                                                                   
# pane border                                                      
set -g pane-border-fg black                                        
set -g pane-border-bg default                                      
set -g pane-active-border-fg yellow                                
set -g pane-active-border-bg default                               
                                                                   
# command line/message text                                        
set -g message-bg black                                            
set -g message-fg yellow                                           
                                                                   
# pane number display                                              
set -g display-panes-active-colour yellow                          
set -g display-panes-colour brightblue                             
                                                                   
# clock                                                            
setw -g clock-mode-colour yellow                                   
# --- end colors
Screenshot

full screen

Last edited by drm00 (2014-03-25 18:37:46)

Offline

#2 2013-05-28 05:45:57

thirtypancakes
Member
Registered: 2013-05-28
Posts: 3

Re: Getting solarized colors right with urxvt, st, tmux and vim

The TERMINFO hack seems unnecessary. Instead you could just set  st's TERM to xterm-256color, which worked for me.

For example, in config.h change:

static char termname[] = "st";

to:

static char termname[] = "xterm-256color";

EDIT: config.h example

Last edited by thirtypancakes (2013-05-28 05:51:06)

Offline

#3 2013-05-28 07:02:07

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,367
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim

If I have to remove the oversized image a third time, I'll just delete the thread instead:
-- mod edit: read the rules and only post thumbnails https://bbs.archlinux.org/viewtopic.php?id=61754  [jwr] --


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#4 2013-05-28 07:55:49

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

jasonwryan wrote:

If I have to remove the oversized image a third time, I'll just delete the thread instead:
-- mod edit: read the rules and only post thumbnails https://bbs.archlinux.org/viewtopic.php?id=61754  [jwr] --

Sorry for the trouble, but i didn't had these problems.  After your first advise, I embedded the small preview image from imgur and checked with firefox and chrome, and for me the size was alright.  But i guess i just leave it like this for now.

Offline

#5 2013-05-28 08:12:29

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

thirtypancakes wrote:

The TERMINFO hack seems unnecessary. Instead you could just set  st's TERM to xterm-256color, which worked for me.

For example, in config.h change:

static char termname[] = "st";

to:

static char termname[] = "xterm-256color";

EDIT: config.h example

Hi,

thanks for your reply. Did you check with vim inside tmux? That used to break the colors when i wasn't using a 16 color xterm; in fact, all 256-color-terminals broke the colors for me, even if the values were close, they never had the exact right values. I am at work right now, but will try out later when i'm at home.

Best,
drm00

Offline

#6 2013-05-28 17:28:24

thirtypancakes
Member
Registered: 2013-05-28
Posts: 3

Re: Getting solarized colors right with urxvt, st, tmux and vim

drm00 wrote:
thirtypancakes wrote:

The TERMINFO hack seems unnecessary. Instead you could just set  st's TERM to xterm-256color, which worked for me.

For example, in config.h change:

static char termname[] = "st";

to:

static char termname[] = "xterm-256color";

EDIT: config.h example

Hi,

thanks for your reply. Did you check with vim inside tmux? That used to break the colors when i wasn't using a 16 color xterm; in fact, all 256-color-terminals broke the colors for me, even if the values were close, they never had the exact right values. I am at work right now, but will try out later when i'm at home.

Best,
drm00


I'm not sure the colors in vim are absolutely correct, but I'll attach a screenshot so you can judge for yourself.

Here's a screenshot comparing vim in tmux/st and vim in plain st.

Offline

#7 2013-05-28 23:20:44

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

Ok, I tried it now with xterm-256color, but i dont think we have to change the termname at all, because i got the same results with st-256color. Will adjust the patches/post tomorrow, thanks for your feedback!

Offline

#8 2013-05-29 00:09:59

thirtypancakes
Member
Registered: 2013-05-28
Posts: 3

Re: Getting solarized colors right with urxvt, st, tmux and vim

No worries. Thanks for the awesome patches! smile

Offline

#9 2013-06-01 01:00:43

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

Updated post, urxvt now works, too (at least on arch); new patches and screenshots.

Offline

#10 2013-06-05 01:57:22

jonyamo
Member
Registered: 2011-03-16
Posts: 5

Re: Getting solarized colors right with urxvt, st, tmux and vim

First off, thanks for the excellent info! Secondly, maybe I'm missing something but your st patches linked in your first post don't seem to work. All three of them just load a blank prompt on hastebin...

Offline

#11 2013-06-05 08:45:06

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

Hi jonyamo, thanks for the hint. Seems that hastebin takes its name too seriously, so i uploaded all patches to github.

Offline

#12 2013-08-29 20:43:56

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

Update to st revision 587bc939f63b49c6155c4f1fdf97e73380207446.

Offline

#13 2013-10-13 22:57:42

addisonamiri
Member
From: United States
Registered: 2013-05-17
Posts: 8

Re: Getting solarized colors right with urxvt, st, tmux and vim

Any idea how to change the colors of the startup and login shell to solarized? I read something about passing parameters to the kernel on boot but I couldn't figure out how it's done. After that it's just a matter a grub theme and you'll never have a black background big_smile

Offline

#14 2013-10-13 23:03:14

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,367
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#15 2014-04-17 19:09:17

cercasi2
Member
From: Kreuzberg 61
Registered: 2009-02-17
Posts: 6

Re: Getting solarized colors right with urxvt, st, tmux and vim

hello,

thanks for the patches and the detailed instructions.

I still have to use xterm (for which solarized works very well), because, for some reason, I can't get st to load *adobe source code pro*. Would you mind sharing your config.h for st as well??

Offline

#16 2014-04-30 12:05:11

drm00
Member
Registered: 2010-06-01
Posts: 38

Re: Getting solarized colors right with urxvt, st, tmux and vim

Hi Cercasi,

for the font, i have

static char font[] = "Source Code Pro Medium-18:style=Regular";

Besides the solarized patch, this is the only change i made to my config.h.

Offline

#17 2014-04-30 12:30:47

cercasi2
Member
From: Kreuzberg 61
Registered: 2009-02-17
Posts: 6

Re: Getting solarized colors right with urxvt, st, tmux and vim

thanks!
Your suggestions works well. My problem was that I use a rather small font and "source code pro" doesn't seem to produce nice results for that. Therefore, I settled with

static char font[] = "Bitstream Vera Sans Mono-9:pixelsize=10.754";

Offline

#18 2014-05-11 07:43:33

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim

@drm00

Thanks for your provided guidelines. I am currently using your colours with Urxvt. However, I discovered that the grey colour is hard to read.

Example from htop: http://i.imgur.com/d9LekJu.png

What colour change would you advise to make grey more readable?

Last edited by orschiro (2014-05-11 07:44:04)

Offline

#19 2014-05-12 15:41:08

serdotlinecho
Member
Registered: 2013-01-26
Posts: 100

Re: Getting solarized colors right with urxvt, st, tmux and vim

orschiro wrote:

@drm00

Thanks for your provided guidelines. I am currently using your colours with Urxvt. However, I discovered that the grey colour is hard to read.

Example from htop: http://i.imgur.com/d9LekJu.png

What colour change would you advise to make grey more readable?

@orschiro try htop-solarized patch.

Offline

#20 2014-05-12 16:47:04

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim

@serdotlinecho

Thanks for the package link! Does that mean that this is an application issue rather than a shortcoming of the colours declared in .Xresources?

In fact, I am noticing the same issue with pachist-git:

vhdSHwv.png

Offline

#21 2014-05-13 16:44:21

Almehdin
Member
Registered: 2012-05-05
Posts: 26

Re: Getting solarized colors right with urxvt, st, tmux and vim

orschiro wrote:

@serdotlinecho

Thanks for the package link! Does that mean that this is an application issue rather than a shortcoming of the colours declared in .Xresources?

In fact, I am noticing the same issue with pachist-git:

http://i.imgur.com/vhdSHwv.png

The easiest would probably be to just change the color in /bin/pachist. It Just bash so open it as root with your text editor and change 'col_1="black" ' to something else.

Offline

#22 2014-05-14 08:59:26

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim

Can someone help me finding the exact hex code for the default font colour? I thought it was #839496 but this does not give me an exact fit:

48itxMf.png

Last edited by orschiro (2014-05-14 21:47:36)

Offline

#23 2014-05-31 18:20:43

user0001
Member
Registered: 2014-05-31
Posts: 1

Re: Getting solarized colors right with urxvt, st, tmux and vim

@drm00:

Thanks for the guide + diffs.

1. The diffs don't seem to work for the latest st (0.5)
2. In your steps, in the section "Create your config.h and adjust the solarized colors":
--- you have this first:
$ cp config.def.h config.h
$ git add config.h
...but really I believe you want to apply the diff patches first, as the diff patches apply to config.def.h.

Offline

#24 2014-10-26 13:17:52

svxiii
Member
Registered: 2014-09-17
Posts: 21

Re: Getting solarized colors right with urxvt, st, tmux and vim

Small problem when running vim:

CSApprox skipped; terminal only has 16 colors, not 88/256
Try checking :help csapprox-terminal for workarounds
Press ENTER or type command to continue

Any way I can get rid of the error?

Offline

#25 2014-10-26 13:22:44

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Getting solarized colors right with urxvt, st, tmux and vim

@svxiii

What terminal are you using?

Try a terminal with support for 256 colour, e.g. rxvt-unicode

Offline

Board footer

Powered by FluxBB