terminal-size

Reliably get the terminal window size (columns & rows)

MIT 2 个版本
安装
npm install terminal-size
yarn add terminal-size
pnpm add terminal-size
bun add terminal-size
README

terminal-size

Reliably get the terminal window size

Because process.stdout.columns doesn't exist when run non-interactively, for example, in a child process or when piped. This module even works when all the TTY file descriptors are redirected!

Confirmed working on macOS, Linux, and Windows.

Install

npm install terminal-size

Usage

import terminalSize from 'terminal-size';

terminalSize();
//=> {columns: 143, rows: 24}

API

terminalSize()

Returns an object with columns and rows properties.

版本列表
4.0.1 2026-02-02
4.0.0 2023-11-04