The setterm
utility is intended for use with the Linux console. According to the console_codes manual page:
The Linux console implements a large subset of the VT102 and
ECMA-48/ISO 6429/ANSI X3.64 terminal controls, plus certain private-
mode sequences for changing the color palette, character-set mapping,
and so on.
Since the program is hard-coded,
/* -regtabs. */
if (ctl->opt_regtabs && vc_only(ctl, "--regtabs")) {
int i;
fputs("\033[3g\r", stdout);
for (i = ctl->opt_rt_len + 1; i <= TABS_MAX; i += ctl->opt_rt_len)
printf("\033[%dC\033H", ctl->opt_rt_len);
putchar('\r');
}
it just happens to work with xterm since xterm implements VT100 controls (plus more).
As for large subset, that is debatable. In a quick count of the items in console_codes
, I see 79 control sequences. That is far less than any of the xterm look-alikes documented in the xterm FAQ Comparing versions, by counting controls. By itself, 79 is not large. The VT102 itself (not an xterm look-alike) had 104. ISO-6429 (aka ECMA-48) documents 20 modes and 162 sequences. Whether you count the total as 182 or 162, 50% is not a large subset.
Rather than using a Linux console utility, there is a more portable choice: the tabs
utility (in POSIX as well as Solaris). It is part of the ncurses utilities (and probably installed on your Linux system).
For the example given in the question, you could do this:
tabs -4
That uses the terminal database, rather than being hard-coded. Tabs and the control sequences to set them are documented in ECMA-48 and other places such as the terminfo(5) manual page.
And tabs
works with xterm.
man -k tab|grep -i -v table |grep -i -v database
would have uncovered it decades ago. – Erik Bennett Sep 08 '17 at 15:04