How can I change the colors of fbterm using escape sequences?

2

From fbterm(1) we can read:

FbTerm supports xterm's 256 color mode extension.  (...)  But xterm's 256 color escape sequences conflict with the linux sequences implemented by FbTerm, so private escape sequences were introduced to support this feature:

   ESC [ 1 ; n }                   set foreground color to n (0 - 255)
   ESC [ 2 ; n }                   set background color to n (0 - 255)
   ESC [ 3 ; n ; r ; g ; b }       set color n to (r, g, b) , n, r, g, b all in (0 - 255)

How can these escape sequences be written with the command echo -ne?

merryup

Posted 2014-08-31T22:40:17.953

Reputation: 21

Answers

2

You can use e.g.

echo -ne "\E[2;32} "

which should print a blue space. (32 is the 32nd colour in the default 8-bit colour table which seems to be blue.)

(Of course you can also use \x1b or \033 instead of \E to represent the escape character.)

To view all 255 colours you can use for i in {0..255}; do echo -ne "\E[2;$i} "; done; tput sgr0; echo or for i in {0..255}; do echo -ne "\E[2;$i}$i "; done; tput sgr0; echo which also includes the number of the colour.

Example: colour output example captured with fbgrab from framebufferconsole

Kai

Posted 2014-08-31T22:40:17.953

Reputation: 33

Do you have a reference for the default colour palette? – Attie – 2018-10-06T22:52:59.257

No, but you could try something like for i in {0..255}; do echo -ne "\E[2;$i} "; done; tput sgr0; echo, this should print 255 coloured spaces and reset every text-colour-related setting to defaults in the end (tput sgr0). – Kai – 2018-10-09T05:31:28.567

Indeed - perhaps you could add this to your answer with a screenshot of the result? Numbers in the color would be even better :-) – Attie – 2018-10-09T09:21:46.947

1Done, I added both one-liners (-: – Kai – 2018-10-10T07:38:39.510

How do you end the color without tput sgr0 ? What is the escape sequence? – Gringo Suave – 2019-09-14T21:22:25.727