Set own RGB palette in the Terminal

Can I set my own RGB color palette in the terminal in the program? If so, in what way?

Yes, from settings in terminal or using Theme Manager (HaikuDepot).

Do you mean setting them manually as an user, or setting them from an application? The latter is possible using some escape sequences, as far as I know we should be following the standards set by Linux terminals.

I am trying to set the palette with esc sequence:

#27’]P’
or
#27’]1337;SetColors=’

but it doesn’t work.

The first one should work, I think.
I’m not sure what exact sequence is recognized, but it looks like ESC ‘]P4;c;xxx’ BEL where c is the color number you want to change (0-255) and xxx is the color specification. Acceptable formats for the specification:

rgb:xx/xx/xx
#xxxxxx
rgb:xxxx/xxxx/xxxx
#xxxxxxxxxxxx
cmyk:c.c/m.m/y.y/k.k
cmy:c.c/m.m/y.y

color names from https://git.haiku-os.org/haiku/tree/src/apps/terminal/XColors.rdef can also be used.

Parsing happens here: https://git.haiku-os.org/haiku/tree/src/apps/terminal/TermParse.cpp?id=fe3e5f05a1f6bc5c291c2e600f9b57180861197a#n1058 and here: https://git.haiku-os.org/haiku/tree/src/apps/terminal/Colors.cpp?id=fe3e5f05a1f6bc5c291c2e600f9b57180861197a#n287