DECRQSS — Request Selection or Setting (DCS $ q ... ST)
Ask the terminal to report the current value of any SGR / mode / margin / cursor-shape setting — the catch-all DCS query.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1bP$q<P>\x1b\\\033P$q<P>\033\\\eP$q<P>\e\\ESC P $ q <P> ESC \1b 50 24 71 ... 1b 5cDescription
Request Selection or Setting. A DCS frame whose intermediate is `$` (0x24) and final is `q` (0x71); the body `<P>` names the setting whose value the application wants reported. Common probes: `\x1bP$qm\x1b\\` asks for the active SGR attributes (terminal replies `\x1bP1$rm\x1b\\` listing the current colour/style stack), `\x1bP$q r\x1b\\` (the literal sequence `$ q SP r`) reports DECSTBM scroll-region margins, `\x1bP$q" p\x1b\\` reports the DECSCL conformance level, `\x1bP$q" q\x1b\\` reports DECSCA character protection, and `\x1bP$q q\x1b\\` (` SP q`) reports the active DECSCUSR cursor shape. The reply uses the same DCS shape — leading byte `1` (valid + supported) or `0` (invalid request), then `$r`, the requested-setting bytes, and ST. Modern apps use DECRQSS in startup probes so they can restore the terminal's pre-existing state when they exit — `vim`'s `t_RV` autodetection, `bat`'s syntax-theme picker, and `kitty kitten themes` all rely on it.
Spec citation: xterm-ctlseqs (DECRQSS, DCS $ q Pt ST)
Examples
# Ask for the current SGR attributes; reply lands on stdin in raw mode.\nstty -echo raw min 0 time 5\nprintf '\033P$qm\033\\'; IFS= read -r -t 1 -d '\\' REPLY; stty sane\necho "DECRQSS m reply: $REPLY"import sys; sys.stdout.write('\x1bP$qm\x1b\\\\') # reply arrives on stdinfmt.Print("\x1bP$qm\x1b\\\\") // request current SGRprocess.stdout.write('\x1bP$qm\x1b\\\\') // request current SGR; read process.stdinprintf("\x1bP$qm\x1b\\\\"); fflush(stdout); /* read DCS reply from stdin */Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- partial
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- no
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- partial
- Konsole
- partial
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | partial | partial | no | yes | no | yes | yes | partial | partial | no | no |