Reference Overview

The pages you will keep open in a second tab while you work.

PageUse it for
GlossaryEvery term, defined precisely, with the loose usage named as loose
Escape Sequence Cheat SheetEvery sequence you implement, with a shell command that generates it
termios Cheat SheetEvery flag, every control character, the stty equivalents
Key Encoding TableThe specification for terminal-input — one row per unit test
Primary SourcesThe actual standards, which to read, and which to ignore
The Terminal EcosystemWhat every real terminal and multiplexer is, and what to steal from each

The Five-Minute Diagnostic

Bookmark this block. It resolves most terminal confusion.

# WHAT am I connected to?
tty; echo $TERM; stty size
ps -o pid,ppid,pgid,sid,tpgid,stat,tty,comm -p $$

# WHAT is the line discipline doing?
stty -a
stty -a -F /dev/pts/N     # Linux, another terminal
stty -a -f /dev/ttysNNN   # macOS

# WHAT bytes is my keyboard sending?
cat -v
stty raw -echo; head -c 20 | xxd; stty sane

# WHAT bytes is that program emitting?
script -q -c 'the-program' /dev/null | cat -v | head -40

# WHERE is the cursor, really?
printf '\033[6n'; read -r -d R p; echo; echo "${p#*[}"

# MY TERMINAL IS BROKEN
stty sane            # input broken (press Ctrl+J if Enter does nothing)
printf '\033c'       # display broken — RIS, hard reset
reset                # both
# turn off everything a crashed TUI may have left on:
printf '\033[?1000l\033[?1002l\033[?1003l\033[?1006l\033[?2004l\033[?1004l\033[?25h\033[?1049l\033[0m'

Which Page Answers Which Question

QuestionPage
"What does CSI 1;5 A mean?"Escape sequences
"What byte does Ctrl+Alt+Shift+F5 send?"Key encoding
"Which flag makes ^C a signal?"termios
"What exactly is a controlling terminal?"Glossary
"Where is this behavior actually specified?"Primary sources
"How does Ghostty differ from Alacritty?"Ecosystem
"Why is Enter 0x0D?"The Hitchhiker's Guide

The Numbers Worth Memorizing

ValueMeaning
0x07BEL — bell, and an OSC terminator
0x08BS — cursor left; does not erase
0x09HT — tab
0x0ALF — down a line, not to column 0
0x0DCR — column 0. The Enter key sends this.
0x1BESC — the escape introducer, and Ctrl+[
0x7FDEL — the Backspace key sends this
0x1B 0x5BCSI — Control Sequence Introducer
0x1B 0x4FSS3 — application-mode cursor keys and F1–F4
0x1B 0x5DOSC — Operating System Command
0x1B 0x5CST — String Terminator
?1049Alternate screen + save cursor + clear
?1DECCKM — application cursor keys
?7DECAWM — autowrap (default on)
?25DECTCEM — cursor visible (default on)
?2004Bracketed paste
?1006SGR mouse encoding

The Ctrl rule: Ctrl + char = uppercase(char) & 0x1F. The modifier parameter: 1 + shift(1) + alt(2) + ctrl(4) + super(8). The 256-palette cube: 16 + 36r + 6g + b, levels [0, 95, 135, 175, 215, 255].


Start with the Glossary, or jump to whichever page answers the question in front of you.