Skip to content
>_notebook

Terminals

Emulators, PTYs, escape sequences, and the art of text-mode interfaces

The terminal is one of the oldest interfaces still in daily use — and one of the most misunderstood. This notebook collects what we've learned building terminal tools, emulators, and TUI applications.

Why terminals still matter

Every developer touches a terminal daily, but few understand the layers beneath: PTY pairs, line disciplines, escape sequence parsers, and the rendering pipeline that turns bytes into pixels. Understanding these layers makes you a better toolsmith.

Key concepts

  • PTY (pseudo-terminal) — the kernel abstraction that pairs a master and slave device, giving userland programs the illusion of a real terminal
  • ANSI/VT sequences — the escape codes that control cursor position, colors, and formatting
  • Line discipline — the kernel module that handles ^C, ^Z, echo, and canonical mode
  • Terminal emulator — the program that renders the grid, parses sequences, and manages scrollback
  • The TTY Demystified by Linus Akesson — the single best introduction to Unix TTY internals
  • ANSI Escape Sequences (Wikipedia) — surprisingly thorough reference for CSI sequences
  • XTerm Control Sequences (invisible-island.net) — the definitive spec for xterm-compatible sequences
  • Writing a Terminal Emulator by @pstrikos — real-world architecture notes

Tools worth knowing

  • tmux / zellij — terminal multiplexers for session management and pane splitting
  • wezterm — GPU-accelerated terminal with Lua config, built in Rust
  • kitty — another GPU-accelerated option with its own graphics protocol
  • alacritty — minimal, fast, OpenGL-based terminal