Expand description

A simple utility for getting the size of a terminal.

Supports both Linux, MacOS, and Windows.

This crate requires a minimum rust version of 1.48.0 (2020-11-19)


use terminal_size::{Width, Height, terminal_size};

let size = terminal_size();
if let Some((Width(w), Height(h))) = size {
    println!("Your terminal is {} cols wide and {} lines tall", w, h);
} else {
    println!("Unable to get terminal size");



Returns the size of the terminal defaulting to STDOUT, if available.

Returns the size of the terminal using the given file descriptor, if available.