Where can I find documentation about GNU/Linux TTY formatting

Posted on

Problem :

On gnu.org site there is GNU Head that can be display on terminal it have XTerm compatible (Normal documented ANSI Codes) but it also contain TTY version (it work on Cygwin, didn’t test in XTerm or real terminal).

It contain text like:

]Pf767676[1;37mâ]Pf9e9e9e[1;37mâ]P7bcbcbc[47m]Pfeeeeee[1;37mâ]

it have x1b then ]Pf767676 and then normal [1;37m which is documented for instance on wikipedia. What is ]Pf767676 and where it’s documented?

Solution :

For Linux console specifically, there is the console_codes(4) manual page. It lists the sequences inherited from VT102, ECMA-48, DEC, and several private ones.

For example, all sequences starting with ESC [ (shorthand CSI) are documented under “ECMA-48 CSI sequences”; they also work the same way on all terminals (or don’t work at all).

On the other hand, ESC ] (shorthand OSC) sequences are private to each terminal, and their documentation in this manpage is scattered in various places; ESC ] P is described as:

       ESC ]     OSC      (Should be: Operating  system  command)  ESC  ]  P
                          nrrggbb:  set  palette,  with parameter given in 7
                          hexadecimal digits after the final P :-(.  Here  n
                          is  the  color  (0-15),  and  rrggbb indicates the
                          red/green/blue values (0-255).   ESC  ]  R:  reset
                          palette

In other words, the sequence ESC ] P f 767676 makes the 15th color in the pallete to be hexadecimal #767676.

Leave a Reply

Your email address will not be published. Required fields are marked *