Skip to content

sindresorhus/terminal-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e2393bc · Nov 4, 2023

History

42 Commits
Nov 4, 2023
Feb 18, 2018
Dec 31, 2018
Feb 18, 2018
Feb 18, 2018
Aug 18, 2021
Nov 4, 2023
Nov 4, 2023
Nov 4, 2023
Oct 25, 2020
Nov 4, 2023
Nov 4, 2023
Nov 4, 2023

Repository files navigation

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.

Related