Search code examples
consolextermansi-escape

Disable/reset bold in xterm


With escape sequences "\033[21m" is used to reset/remove bold/bright:

echo -e "Text\033[1mMore text\033[21mEnd"

must return:

TextMore textEnd

but I get

TextMore textE̲n̲d̲

As you can see, in xterm "\033[21m" changes to underline and to reset bold we need to use "\033[0m", why is this?

Is there a way to change this behavior? (maybe launching xterm with some parameter)


Solution

  • According to XTerm Control Sequences, SGR 21 is "doubly-underlined":

    CSI Pm m  Character Attributes (SGR).
    
            Ps = 2 1  -> Doubly-underlined (ISO 6429).
            Ps = 2 2  -> Normal (neither bold nor faint).
            Ps = 2 3  -> Not italicized (ISO 6429).
            Ps = 2 4  -> Not underlined.
            Ps = 2 5  -> Steady (not blinking).
            Ps = 2 7  -> Positive (not inverse).
            Ps = 2 8  -> Visible, i.e., not hidden (VT300).
            Ps = 2 9  -> Not crossed-out (ISO 6429).
    

    Perhaps you intended SGR 22.

    The doubly-underlined feature was implemented in xterm patch #305:

    minor reorganization to implement “filler” SGR features. There are no established applications which rely upon these; some people find them amusing.

  • separate bits used to manage drawing state from attribute-bits.
  • implement SGR codes 2, 3, 9, 21 and their corresponding resets.
  • add configure option --disable-wide-attrs to disable the feature.