REP — Repeat Preceding Character (CSI Pn b)
Repeat the most-recently-emitted printing character N times — a bandwidth-saver for runs of identical glyphs.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[Pnb\033[Pnb\e[PnbESC [ Pn b1b 5b <Pn> 62Description
Repeat Preceding Character. Final byte `b` (0x62) prints the most-recent graphic character (the one that updated the terminal's display, NOT a control code or whitespace) `Pn` more times (default 1). If the previous emitted byte was a control or none-yet, REP is a no-op. Useful in narrow SSH links: drawing a horizontal rule of 80 `─` chars costs 80 multi-byte UTF-8 bytes (160-240 bytes) versus `─\x1b[79b` (5 bytes + 4 control bytes = 9 bytes). Supported by xterm (since X11R5), kitty, wezterm, ghostty, alacritty, mintty, foot; Windows Terminal added support in 1.18+; iTerm2 doesn't support it. Apps that emit decorative box-drawing or progress-bar fills can preflight via XTGETTCAP for the `rep` cap before using it. Terminfo cap: `rep`.
Spec citation: ECMA-48 §8.3.103 (REP)
Examples
# 80-char horizontal rule with minimal bytes:\nprintf '\xe2\x94\x80\033[79b\n'import sys; sys.stdout.write('-\x1b[79b\n') # 80 dashesfmt.Print("-\x1b[79b\n")process.stdout.write('-\x1b[79b\n')printf("-\x1b[79b\n");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- no
- iTerm2
- no
- Windows Terminal
- yes
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- partial
- Konsole
- yes
- 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 | yes | no | no | yes | no | yes | yes | yes | yes | partial | yes | no | no |