Reputation: 220
I have a perl script which randomly selects a FG and BG colors for my terminal. I use the following print commands to set the FG and BG on the fly:
print "\033]10;<fg_color>\007";
print "\033]11;<bg_color>\007";
I need to set the palette colors too, but i'm having problems finding an example on how to do it. Can any one help me?
Upvotes: 1
Views: 165
Reputation: 54563
If your terminal implements xterm's OSC 10 and OSC 11 as indicated in the question, then it probably also implements OSC 4:
Ps = 4 ; c ; spec ⇒ Change Color Number c to the color specified by spec.
For example
print "\033]4;1;green\007";
print "\033]4;1;green\033\\";
using green to replace color 1 (red) where xterm also would accept an RGB setting:
/*
* Set or query entries in the Acolors[] array by parsing pairs of color/name
* values from the given buffer.
*
* The color can be any legal index into Acolors[], which consists of the
* 16/88/256 "ANSI" colors, followed by special color values for the various
* colorXX resources. The indices for the special color values are not
* simple to work with, so an alternative is to use the calls which pass in
* 'first' set to the beginning of those indices.
*
* If the name is "?", report to the host the current value for the color.
*/
The legal values for spec are determined by XParseColor
(in xterm -- for other terminals, that is implementation-dependent and generally undocumented, making that aspect off-topic).
Upvotes: 1
Reputation: 23876
I do not think, that you can set the palette. You just can select from the palette. See here for examples.
The palette depends on your Terminal. For XTerm the palette is set in ~/.Xresources
. This is my current configuration:
XTerm*color0: rgb:00/00/00
XTerm*color1: rgb:80/00/00
XTerm*color2: rgb:00/80/00
XTerm*color3: rgb:80/80/00
XTerm*color4: rgb:00/00/80
XTerm*color5: rgb:80/00/80
XTerm*color6: rgb:00/80/80
XTerm*color7: rgb:c0/c0/c0
XTerm*color8: rgb:80/80/80
XTerm*color9: rgb:aa/00/00
XTerm*color10: rgb:00/aa/00
XTerm*color11: rgb:aa/aa/00
XTerm*color12: rgb:00/00/aa
XTerm*color13: rgb:aa/00/aa
XTerm*color14: rgb:00/aa/aa
XTerm*color15: rgb:ff/ff/ff
Upvotes: 0