How to Make the Watch Command Interpret Vt100 Sequences

How can I make the watch command interpret vt100 sequences?

Edit:

More recent versions of watch support color. You will need to use an extra level of quoting to preserve the quotes and escapes in the particular situation of the example in the question:

watch 'echo -e "\033[31mHello World\033[0m"'

From man watch:

  -c, --color
Interpret ANSI color sequences.

Previously:

From man watch:

Non-printing characters are stripped from program output. Use "cat -v"
as part of the command pipeline if you want to see them.

But they don't get interpreted, so I don't think there's any way.

bash-program watch and ANSI escape sequences in the output

The --color option does the trick for me.

watch --color -n 1 "echo -e '\033[36mHello World\033[0m'"

Or, in the absence of the color option, how about a home-grown watch:

while [ 1 ]; do clear; echo -e '\033[36mHello World\033[0m'; sleep 1; done

Colors with unix command watch?

Some newer versions of watch now support color.

For example watch --color ls -ahl --color.

Related.

How to make win32 console recognize ANSI/VT100 escape sequences?

[UPDATE] For latest Windows 10 please read useful contribution by @brainslugs83, just below in the comments to this answer.

While for versions before Windows 10 Anniversary Update:

ANSI.SYS has a restriction that it can run only in the context of the MS-DOS sub-system under Windows 95-Vista.

Microsoft KB101875 explains how to enable ANSI.SYS in a command window, but it does not apply to Windows NT. According to the article: we all love colors, modern versions of Windows do not have this nice ANSI support.

Instead, Microsoft created a lot of functions, but this is far from your need to operate ANSI/VT100 escape sequence.

For a more detailed explanation, see the Wikipedia article:

ANSI.SYS also works in NT-derived systems for 16-bit legacy programs executing under the NTVDM.

The Win32 console does not natively support ANSI escape sequences at all. Software such as Ansicon can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.

So I think ANSICON by Jason Hood is your solution. It is written in C, supports 32-bit and 64-bit versions of Windows, and the source is available.

Also I found some other similar question or post which ultimately have been answered to use ANSICON:

  • How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?
  • how to use ansi.sys in windows 7
  • How can I get cmd.exe to display ANSI color escape sequences?
  • ansi color in windows shells
  • enable ansi colors in windows command prompt

How to determine graphics capabilities of an x11 terminal window

Actually kterm provides Tek4014 emulation according to its menus. You are probably referring to KDE konsole, which does not. TeraTerm (a Windows application) reportedly also supports the feature.

Back to the point: there is no useful method for telling if a given terminal supports a given feature. Some terminals return status information which tells what type of terminal it is, and what optional features it may have (based on the device responses from DEC and similar terminals). The Tektronix terminal had no such status query/response (refer to XTerm Control Sequences).

Relying upon the status responses in any case doesn't give much assurance since some developers hard-code responses to match xterm.

Since the terminal will not tell you, the only way to verify that would be by actual inspection. Someone might construct a program that could do screendumps and verify that the terminal responds to the sequences, but there's still the pitfall that the switching between vt100(or similar) and tek4014 may not be done with the same escape sequence used in xterm. After all, that escape sequence is not in the standard repertoire of any hardware terminal.



Related Topics



Leave a reply



Submit