Skip to content
astralbluePublic

About

resizewin detects the terminal size

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

resizewin: Detect and configure terminal size

Usage

From a terminal shell

eval `resizewin`

It works with VT100-compatible terminals, including all modern terminal emulators.

From Python code

import sys
import termios

import resizewin

fd = sys.stdin.fileno()
rows, cols = resizewin.get_terminal_size(fd)
termios.tcsetwinsize(fd, (rows, cols))

How it works

In order to detect the terminal size, resizewin first tells the terminal to move the cursor to as far as possible, then asks the terminal for the current cursor's position. It uses the fact that terminals move the cursor to the bottom right corner when told to move the cursor to a row/column position that exceeds screen size.

About

resizewin detects the terminal size

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages