Skip to main content
ansicode

DECSCUSR — Cursor shape

Change the cursor shape: block, underline, or bar (with optional blink).

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[N\x20q (N = 0..6)
\\033[\033[1 q
\\e[\e[1 q
ESC [ESC [ N SP q
hex1b 5b <N> 20 71

Description

Set Cursor Style. The parameter selects shape and blink: `0` or `1` = blinking block (default), `2` = steady block, `3` = blinking underline, `4` = steady underline, `5` = blinking bar (vertical line), `6` = steady bar. The intermediate byte is a literal SPACE (0x20) before the final `q`. Vim's `t_SI`/`t_EI` and many shells use `\x1b[6 q` (bar) for insert mode and `\x1b[2 q` (block) for normal mode. Restore your terminal default with `\x1b[0 q` on exit.

Spec citation: xterm-ctlseqs (DECSCUSR, CSI Ps SP q)

Parameters

0user-default cursor
1blinking block
2steady block
3blinking underline
4steady underline
5blinking bar
6steady bar

Examples

bash
printf '\033[6 q'   # vertical bar (insert mode)\nprintf '\033[2 q'   # block (normal mode)\nprintf '\033[0 q'   # restore default
python
import sys; sys.stdout.write('\x1b[6 q')
go
fmt.Print("\x1b[6 q")
javascript
process.stdout.write('\x1b[6 q')
c
printf("\x1b[6 q");

Terminal support

xterm
yes
Linux console (fbcon)
partial
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
partial
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

CSI cookbook · 6. Insert / delete / cursor shape — IL / DL / ICH / DCH / ECH + DECSCUSR