Skip to main content
ansicode

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[\x1b[Pnb
\\033[\033[Pnb
\\e[\e[Pnb
ESC [ESC [ Pn b
hex1b 5b <Pn> 62

Description

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

bash
# 80-char horizontal rule with minimal bytes:\nprintf '\xe2\x94\x80\033[79b\n'
python
import sys; sys.stdout.write('-\x1b[79b\n')   # 80 dashes
go
fmt.Print("-\x1b[79b\n")
javascript
process.stdout.write('-\x1b[79b\n')
c
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

Related sequences