backports.shutil_get_terminal_size

1.0.0 · maintenance · verified Wed Apr 15

This library provides a pure Python backport of the `get_terminal_size` function, originally introduced in Python 3.3's `shutil` module. It allows applications targeting older Python versions (like Python 2.6, 2.7, and 3.2) to access terminal dimension information. Currently at version 1.0.0, the package was last updated in 2014, indicating a stable, low-cadence release cycle typical for a compatibility backport.

Warnings

Install

Imports

Quickstart

This example demonstrates how to import and use the `get_terminal_size` function to retrieve the current terminal's column and line dimensions. The function returns a `terminal_size` named tuple with `columns` and `lines` attributes.

from backports.shutil_get_terminal_size import get_terminal_size

# Get terminal dimensions
terminal_size = get_terminal_size()

print(f"Terminal columns: {terminal_size.columns}")
print(f"Terminal lines: {terminal_size.lines}")

view raw JSON →