By using the ANSI sequence Esc[39m
in a terminal, it is possible to clear the foreground color without altering other attributes like bold, underline, or the background color. For example:
echo -e "\e[31;1mRed and bold.\e[39m Bold only."
I would like to retrieve this sequence from a terminfo capability, but I'm unable to find it; when trying with setaf 9
, it switches to bright colors by giving the sequence Esc[91m
:
$ tput setaf 1 | xxd
00000000: 1b5b 3331 6d .[31m
$ tput setaf 9 | xxd
00000000: 1b5b 3931 6d .[91m
The only capability I found to reset the foreground color is sgr0
, but it resets all the other attributes as well.
Is it possible to access these capabilities from terminfo ?
- Default foreground
Esc[39m
; - Default background
Esc[49m
;