Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use st with solarized colors like I can with urxvt (of course this is done via .Xresources, in st the colors are defined in a header file). I've tried to put the colors in st's config file (config.h), but the colors are "used for the wrong things" in st (eg. dircolors and colors in vim are rearranged relative to urxvt).

I think I have to modify the escape sequences used by st, but I'm not getting anywhere. Can anyone offer me a hint on how to apply the solarized colors to st?

share|improve this question

I have no prior experience with st other than using it, but from glancing at the source I think I have found the parts that are relevant.
I presumed that by use solarized colors you meant that you want all applications that use default blue to instead use solarized blue.

You will need to make some changes to the source in st.c rather than just config.h.
dc is a global variable that is an instance of the DC struct, each dc.cols[i] corresponds to a color to use.

The first 16 colors within config.h colorname are loaded via XAllocNamedcolor within the function xloadcols(void), these are inserted into the first 16 positions (0 to 15) within dc.col.

These correspond to ansi escape sequence colours, for more see ANSI Escape Code::Colors.

You would need to change this funtionality within xloadcols(void), specifically the first for loop.
Instead of using XAllocNamedColor you could instead use XAllocColor (you can see an example of this in the second for loop), this allows you to specify the rgb of each color to be inserted at each position (instead of loading an already known colour from a name).

For the hex values see solarized.vim specifically lines 98 through 116 where the hex values are specified.

The rest of dc.cols is allocated within a for loop, also found within xloadcols(void), you probably shouldn't need to change this although it means some applications may use these colors rather than your solarized ones.

As for the default background and foreground colors these are set within config.h, lines 40 and below.
each #define name index defines dc.col[index] is to be used for name, for example DefaultBg specifies the background color of the terminal.

share|improve this answer
Why do you recommend that I use the srgb rather than hex colors in solarized.vim? – user24483 Nov 3 '12 at 17:25
Didn't see the hex color listing, corrected answer. – cjh Nov 3 '12 at 22:42

For those wanting an example of st's config.h with Solarized colours see his Gist: https://gist.github.com/gregf/5279175

share|improve this answer
up vote 0 down vote accepted

In st tip (and the 0.3 release) it's not necessary to edit st.c, just insert the solarized colors in config.h. It seems that both st.c and config.h has changed since I asked this question.

share|improve this answer

Your Answer


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