HomeTutorials › Interactive Terminal
Interactive Terminal

PTY Resize

#045 0:13 Part of the Rysh video series

Resize the window and your programs follow -- SIGWINCH propagates and the emulator reflows.

PTY Resize — 0:13 walkthrough

What you'll see

  1. Launch rysh and print the size with echo cols=$(tput cols) rows=$(tput lines).
  2. Split with Ctrl+P n, changing pane geometry and firing SIGWINCH.
  3. Re-run the tput echo in the narrower pane to show the reduced column count.
  4. Launch htop to show an interactive program reflowing, then q to quit.

Commands shown

rysh
echo cols=$(tput cols) rows=$(tput lines)
n
echo cols=$(tput cols) rows=$(tput lines)
htop
q

Keys used

EnterCtrl+pEscape

Transcript

0:00Resize the window and your programs follow -- SIGWINCH propagates and the emulator reflows.

0:03Start rysh and check the terminal dimensions.

0:08Run tput to read the current columns and rows -- the values the PTY is reporting to your shell.

0:15Split a pane with Ctrl+P n. Splitting changes each pane's geometry, and Rysh sends a SIGWINCH so the shell learns its new size.

0:23Check again in the narrower pane -- the column count has dropped. The PTY was resized live, no restart needed.

0:30Interactive programs adapt too. Launch htop -- the vt10x emulator reflows its layout to whatever space the pane currently has.

0:37Resize freely. Your shells and full-screen apps reflow to fit.

Key takeaway
Window and pane resizes propagate SIGWINCH so shells and full-screen apps reflow live.