EL — Erase in line (\x1b[K)
Erase part or all of the current line.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[NK\\033[
\033[K\\e[
\e[KESC [
ESC [ N Khex
1b 5b <N> 4bDescription
Final byte `K`. N = 0 erases from the cursor to the end of the line (default), N = 1 erases from the start of the line up to and including the cursor, N = 2 erases the entire current line. The cursor itself is NOT moved by EL — combine with `\r` if you want to overwrite the line from the start.
Spec citation: ECMA-48 §8.3.41 (EL)
Examples
printf 'progress... \r\033[Kdone\n'import sys, time\nfor i in range(3): sys.stdout.write(f'\r\x1b[K{i}'); sys.stdout.flush(); time.sleep(0.2)\nprint()fmt.Print("\r\x1b[Kclear line\n")process.stdout.write('\r\x1b[Kclear line\n')printf("\r\x1b[Kclear line\n");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- yes
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- 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 | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | no | no |