Terminal · Technology
From keypress to pixel: the PTY layer, escape codes, GPU rendering, and the engineering stack that makes a 60-year-old interface screamingly fast in 2025.
01 / Architecture
When you type in a terminal emulator, you're not talking directly to bash. A kernel abstraction called a Pseudo-Terminal (PTY) sits between them, emulating a physical serial line. Understanding PTY is understanding the entire terminal stack.
02 / Protocol
Everything you see in a terminal — colors, bold text, cursor movement, clearing the screen — is controlled by ANSI escape sequences: printable bytes starting with ESC (\x1b, byte 27). Standardized by ANSI X3.64 in 1979 based on the DEC VT100, these sequences are understood by every terminal emulator ever made.
The 16 standard ANSI colors (8 normal + 8 bright). Every terminal emulator supports these — they've been standard since 1979:
03 / Shell
The terminal emulator is just a window. The shell is where the intelligence lives: command parsing, job control, tab completion, history, variables, scripting, and the most powerful text-processing pipeline ever designed.
GNU Bourne-Again Shell. The universal default. ~/.bashrc runs on a billion machines. POSIX-compliant, array support, arithmetic expansion, and 35 years of tribal knowledge baked in.
The power user's shell. Better tab completion, theme support (oh-my-zsh), spelling correction, right-side prompts, and the default on macOS since 10.15 Catalina. ~/.zshrc
Friendly Interactive Shell. Autosuggestions out of the box, web-based config, no POSIX compatibility (intentionally). Makes the terminal approachable for newcomers without sacrificing power.
The terminal's superpower. ps aux | grep nginx | awk '{print $2}' | xargs kill. Chain any command to any other. One-liners that would take 100 lines of Python. Unix philosophy: do one thing well.
Ctrl+R reverse history search. Ctrl+A/E line start/end. Alt+. last argument. !! last command. The keyboard shortcuts that make terminal experts 10× faster than anyone else.
Ctrl+Z suspends. bg backgrounds. fg foregrounds. & runs in background. nohup survives logout. disown detaches from shell. Run 20 things at once.
04 / Rendering
Traditional terminal emulators render on the CPU: measure each glyph, paint pixels in a software framebuffer, copy to the screen. At 4K resolution with a 144Hz display, this is a bottleneck. GPU-accelerated terminals changed everything.
GPU terminals pre-rasterize every character into a texture atlas on the GPU. Rendering a character means sampling a texture — a single GPU instruction, not a full font render. Entire screens render in microseconds.
One draw call renders thousands of glyphs by sending instance data (position, color, glyph index) to a GLSL shader. Modern GPUs do this in parallel across thousands of shader cores simultaneously.
LCD panels have R, G, B subpixels. Subpixel antialiasing addresses each independently, tripling effective horizontal resolution. At 4K on a Retina display, text is indistinguishable from print.
Fonts like Fira Code, JetBrains Mono, and Cascadia Code combine character sequences (-> → →, != → ≠) into single glyphs. GPU rendering makes this free. Code becomes readable at a glance.
05 / Encoding
The original terminal was ASCII: 128 characters, English only. Unicode (1991) assigned a code point to every character in every writing system — over 150,000 characters across 161 scripts. UTF-8 (Ken Thompson & Rob Pike, 1992) made it backward-compatible with ASCII while encoding the full Unicode range.
Variable-width: ASCII characters use 1 byte (backward compatible), most European characters use 2 bytes, CJK use 3 bytes, emoji use 4 bytes. Designed by Ken Thompson on a napkin at a diner in 1992.
CJK characters (Chinese, Japanese, Korean) are "double-width" — they occupy 2 terminal columns. The terminal emulator must account for this when calculating cursor positions and line wrapping.
Some characters modify the character before them (accents, diacritics). e + ◌́ = é. Modern terminals handle combining characters correctly; older ones garble them.
Programmer fonts patched with thousands of icons: git branch (), language icons, Powerline separators (), folder symbols. A Nerd Font turns your shell prompt from text into an information dashboard.
06 / Multiplexing
A terminal multiplexer manages multiple terminal sessions inside a single window. Sessions, windows, and panes. Detach and reattach. Survive SSH disconnects. The operational model of every serious backend engineer.