Search code examples
colorskshqnx-neutrino

How do I add colour to a QNX terminal?


I'm connecting to QNX Neutrino over SSH with PuTTY 0.62.

I've enabled "Allow terminal to specify ASCI colours", and "Allow terminal to use xterm 256-colour mode".

How do I get my terminal (qansi-m) to add colour to the output text?


Solution

  • You can manually add colours by using the following when using echo:

    The graphic rendition codes are as follows:

    Number  Meaning
    0       All attributes off (except charset (10, 11, 12))
    1       Bold
    2       Half intensity (default to cyan on color screen)
    4       Underline (default to red on color screen)
    5       Blink
    7       Reverse
    9       Invisible
    10      Exit alternate char set (GR & GL are restored)
    11      Enter PC-lower char set (GR & GL are ASCII; C0 & C1 are PC_LO except for ESC)
    12      Enter PC-higher char set (GR, C1 & GL, C0 are PC_HI except for ESC)
    21      Normal intensity (un-Bold)
    22      Normal intensity (un-Half intensity)
    24      Disable underline
    25      Disable blink
    27      Disable reverse
    29      Visible
    30-37   Set foreground color (30+color_number, see below)
    39      Set foreground to saved
    40-47   Set background color (40+color_number, see below)
    49      Set background to saved
    

    The color codes are as follows:

    colour_num  Description
    0           Black
    1           Red
    2           Green
    3           Brown
    4           Blue
    5           Violet
    6           Cyan
    7           White
    

    Syntax:

    {CSI}<setting1>;<setting2>m
    

    CSI in octal is \0233, so to print bold text (1) with a red foreground (31), you'd do:

    echo "\023331;1m"
    

    Reference