A terminal is a display unit that is part of the user interface to a computer system. The word carries the connotation of being text-only.

See Also

Various ANSI standards govern terminal behaviour.
A terminal emulator.
A C library for controlling terminals.
handling of ANSI terminals using Expect
The *nix command to configure and manage a terminal.
terminal control sequence


Dedicated to the range of video terminals produced by Digital Equipment Corporation (DEC) from 1970 to 1995. The most famous of these is the VT100.
The TTY demystified , Linus Åkesson, 2008-07-25


Terminal emulators for Linux have support for ANSI escape codes built in.

Checking for a Terminal

AMG: To check if stdin is connected to a terminal, run:

if {![catch {exec /usr/bin/tty -s}]} {
    # stdin is a terminal

Checking for stdout/stderr is harder because exec does not allow stdout/stderr to be redirected to stdin because stdout/stderr are not considered readable. Instead, let the shell do the redirection. Furthermore, instruct [exec] to not intercept stdout/stderr.

if {![catch {exec /bin/sh -c {/usr/bin/tty -s < /dev/stdout} >@ stdout}]} {
    # stdout is a terminal
if {![catch {exec /bin/sh -c {/usr/bin/tty -s < /dev/stderr} 2>@ stderr}]} {
    # stderr is a terminal

Without the -s switch, the tty program not only checks if its stdin is a terminal, but it also prints the device name to its stdout, e.g. /dev/pts/0.