I’m making some post-formatting of a log for better readability.
Using regular expressions, my script recognizes some patterns in the stream and makes the correspondent text bold by inserting the $(tput bold)
and $(tput sgr0)
values at the beginning and at the end of the text respectively. The stream is not textual, it already contains some special formatting escape sequences like colors and so on.
$(tput setaf 6)
Part of this text can be $(tput bold)bold$(tput sgr0) but
the rest of the text has lost its initial color.
The problem is that I cannot figure out how to turn off the bold mode only. Using $(tput sgr0)
drops all the other current terminal settings to their default values, including the color.
I use man terminfo
to know what “capname” I should use. For example, I know how to make some text italic, because the list contains both — the sitm
capname to enter_italic_mode
and the ritm
capname to exit_italic_mode
.
$(tput setaf 6)
Part of this text can be $(tput sitm)italic$(tput ritm) but
the rest of the text still has its initial color.
I’d like to use the same approach to make text bold because the terminfo
list contains the bold
capname to enter_bold_mode
. But there is neither “exit_bold_name” string variable nor a correspondent capname!
Am I missing something? Should I use another approach? In all the articles I have found on the Internet it is used the sgr0
capname solution only.