0

To avoid a subshell, what are the ANSI escape equivalents of tput sgr0 for an ANSI-compatible terminal?

2

You could answer that by looking at the output of infocmp:

infocmp -1 ansi |grep sgr0=

and seeing (for example)

sgr0=\E[0;10m,

which tells you that you could do

printf '\033[0;10m'

to get the same effect as

tput -T ansi sgr0

But you're not using ANSI, but rather some particular terminal, and though the ones you're using are similar, not all are identical. It's more likely that your TERM variable is set to something like "xterm", which (omitting the terminal type) gives

sgr0=\E(B\E[m,

The common part is the \E[m, which is the terminfo syntax for \033[m. The other characters in each sequence are resetting the alternate character set (and can depend on the terminal type).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.