For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
isatty
isatty(fd: Int) -> Bool
Checks whether a file descriptor refers to a terminal.
Returns True if the file descriptor fd is open and connected to a
tty(-like) device, otherwise False. On GPUs, the function always returns
False.
Examples:
from std.os import isatty
# Check if stdout (fd=1) is a terminal
if isatty(1):
print("Running in a terminal")
else:
print("Output is redirected")
Args:
- fd (
Int): A file descriptor.
Returns:
Bool: True if fd is connected to a terminal, False otherwise.