Skip to content

terminalSize ​

terminalSize returns the terminal's [columns, rows].

SignatureterminalSize(): [u16, u16]?
tyrus
import { terminalSize } from "tyrus:os";

const size: [u16, u16]? = terminalSize();
if (size) {
    print(`${size[0]} columns x ${size[1]} rows`);
}

Absence is a valid outcome

Returns absent, not an aborted program, when stdout is not attached to a terminal, piped output, redirected to a file, or a headless process.