Skip to content

isTTY ​

isTTY reports whether stdout is attached to an interactive terminal and returns boolean.

SignatureisTTY(): boolean
tyrus
import { isTTY } from "tyrus:cli";

const interactive: boolean = isTTY();
if (interactive) {
    print("stdout is a terminal");
}

Guard your prompts

A prompt aborts when stdin is not a TTY. Check isTTY() first and offer a non-interactive fallback when it returns false.