Terminal Guide

Control Characters and Escape Sequences

urxvt xterm vte konsole linuxvc other
ENQ
  Answerback (ENQ)
BEL
  Bell (BEL)
BS
  Backspace (BS)
TAB
  Horizontal Tab (TAB)
LF
  Line Feed (LF)
VT
  Vertical Tab (VT)
FF
  Form Feed (FF)
CR
  Carriage Return (CR)
SO
  Shift Out (SO) todo
SI
  Shift In (SI) todo
CAN
  Cancel Parsing (CAN) todo
SUB
  Cancel Parsing (SUB) todo
ESC 6
  Back Index (DECBI) ✔ ✓
ESC 7
  Save Cursor (DECSC)
ESC 8
  Restore Cursor (DECRC)
ESC 9
  Forward Index (DECFI)
ESC D
  Index (IND)
ESC E
  Next Line (NEL)
ESC F
  HP Home Down 🔧
ESC G
  Unsupported Rxvt Graphics
ESC H
  Horizontal Tab Set (HTS)
ESC M
  Reverse Index (RI)
ESC N
  Single Shift 2 (SS2)
ESC O
  Single Shift 3 (SS3)
ESC V
  Start Protected Area (SPA)
ESC W
  End Protected Area (EPA)
ESC Z
  Return Terminal ID (DECID)
ESC c
  Full Reset (RIS) todo todo todo
ESC l
  HP Memory Lock
ESC m
  HP Memory Unlock
ESC n
  Locking Shift 2 (LS2)
ESC o
  Locking Shift 3 (LS3)
ESC >
  Reset Application Keypad Mode (DECKPNM)
ESC =
  Set Application Keypad Mode (DECKPAM)
ESC @
  ???
ESC |
  Locking Shift 3 Right (LS3R)
ESC }
  Locking Shift 2 Right (LS2R)
ESC ~
  Locking Shift 1 Right (LS1R)
ESC # 3
  Set Double Height Line Top Half (DECDHL)
ESC # 4
  Set Double Height Line Bottom Half (DECDHL)
ESC # 5
  Set Single Width Line (DECSWL)
ESC # 6
  Set Double Width Line (DECDWL) todo
ESC # 8
  Fill Screen with E (DECALN)
ESC % 8
  Alias: Enable UTF-8 mode
ESC % G
  Enable UTF-8 mode
ESC % @
  Disable UTF-8 mode
ESC F
  Use 7-bit controls (S7C1T)
ESC G
  Use 8-bit controls (S8C1T)
ESC L
  ANSI Charset Level 1 (ANSI_LEVEL_1)
ESC M
  ANSI Charset Level 2 (ANSI_LEVEL_2)
ESC N
  ANSI Charset Level 3 (ANSI_LEVEL_3)
ESC [ A
  Cursor Up (CUU)
ESC [ A
  Scroll Right (SR)
ESC [ B
  Cursor Down (CUD)
ESC [ C
  Cursor Right (CUF)
ESC [ D
  Cursor Left (CUB)
ESC [ E
  Cursor Next Line (CNL)
ESC [ F
  Cursor Previous Line (CPL)
ESC [ G
  Alias: Cursor Horizontal Position Absolute
ESC [ ; H
  Set Cursor Position (CUP)
ESC [ I
  Cursor Horizontal Forward Tabulation (CHT)
ESC [ J
  Erase Display [Dispatch] (ED)
ESC [ 0 J
  Erase Display Below
ESC [ 1 J
  Erase Display Above
ESC [ 2 J
  Erase Display Complete
ESC [ 3 J
  Erase Display Scroll-back
ESC [ ? J
  Selective Erase Display [DISPATCH] (DECSED)
ESC [ K
  Erase Line [Dispatch] (EL)
ESC [ 0 K
  Erase Line Right
ESC [ 1 K
  Erase Line Left
ESC [ 2 K
  Erase Line Complete
ESC [ 3 K
  Erase Line Right Unless Pending Wrap
ESC [ ? K
  Selective Erase Line [DISPATCH] (DECSEL)
ESC [ L
  Insert Line (IL)
ESC [ M
  Delete Line (DL)
ESC [ P
  Delete Character (DCH)
ESC [ S
  Scroll Up (SU)
ESC [ ? ; ; S
  [Sixel/ReGIS] Graphics Attributes
ESC [ S
  (used by other terminals)
ESC [ T
  Scroll Down (SD)
ESC [ ; ; ; ; T
  Track Mouse
ESC [ > [ ] T
  Unset Title Mode
ESC [ W
  Cursor Tabulation Control
ESC [ ? W
  Set Tab At Every 8 Columns
ESC [ X
  Erase Character (ECH)
ESC [ Z
  Cursor Horizontal Backward Tabulation (CBT)
ESC [ a
  Cursor Horizontal Position Relative (HPR)
ESC [ b
  Repeat Previous Character (REP)
ESC [ c
  Primary Device Attributes (DA1)
ESC [ ? ; ; c
  Linux Cursor Style
ESC [ > c
  Secondary Device Attributes (DA2)
ESC [ = c
  Tertiary Device Attributes (DA3)
ESC [ d
  Cursor Vertical Position Absolute (VPA)
ESC [ d
  Unset Tab Stop
ESC [ e
  Vertical Position Relative (VPR)
ESC [ ; f
  Alias: Set Cursor Position
ESC [ g
  Tab Clear (TBC)
ESC [ [ ] h
  Set Mode (SM)
ESC [ ? [ ] h
  Set Mode (?) (SM)
ESC [ i
  Media Control (MC)
ESC [ 0 i
  Media Control: Print Terminal Contents 🔧
ESC [ 10 i
  Save Screenshot in HTML Format
ESC [ 11 i
  Save Screenshot in SVG Format
ESC [ 4 i
  Media Control: Disable Printer Redirection and Auto Print
ESC [ 5 i
  Media Control: Redirect Stream to Printer 🔧
ESC [ ? i
  Media Control (?) (MC) 🔧
ESC [ ? 1 i
  Media Control: Print Current Line 🔧
ESC [ ? 10 i
  Media Control: Alias: Print Terminal Contents 🔧
ESC [ ? 11 i
  Media Control: Print terminal Contents including Scrollback 🔧
ESC [ ? 4 i
  Media Control: Alias Disable Printer Redirection and Auto Print
ESC [ ? 5 i
  Media Control: Auto Print Finished Lines 🔧
ESC [ j
  Alias: Cursor Left
ESC [ k
  Alias: Cursor Up
ESC [ k
  (used by other terminals)
ESC [ [ ] l
  Reset Mode (RM)
ESC [ ? [ ] l
  Reset Mode (?) (RM)
ESC [ [ ] m
  Select Graphic Rendition (SGR)
ESC [ ? ; m
  Linux Mouse Pointer Style
ESC [ > m
  Configure Modifier Key Reporting Formats
ESC [ > 0 ; m
  Allow Systematic Modifier Reporting in Legacy and VT220 Mode
ESC [ > 1 ; m
  Select Format for Modifier Keys in Cursor Key Press Reports
ESC [ > 2 ; m
  Select Format for Modifier Keys in Function-Key Key Press Reports
ESC [ > 4 ; m
  Select Format for Modifier Keys in Other Key Press Reports (modify other)
ESC [ n
  Device Status Report [Dispatch] (DSR)
ESC [ 5 n
  Request Operating Status
ESC [ 6 n
  Request Cursor Postion Report (CPR)
ESC [ 7 n
  ???
ESC [ 8 n
  Set Title to Terminal Name and Version.
ESC [ ? n
  Device Status Report (?) [Dispatch] (DSR)
ESC [ ? 15 n
  DSR 13 (historically: Printer Status)
ESC [ ? 25 n
  DSR 25 (historically: User Defined Key Status)
ESC [ ? 26 n
  DSR 26 (historically: Keyboard Status)
ESC [ ? 5 n
  Request Operating Status (?)
ESC [ ? 53 n
  Alias: Request DEC Locator Status
ESC [ ? 55 n
  Request DEC Locator Status
ESC [ ? 56 n
  Request DEC Locator Type
ESC [ ? 6 n
  Request Cursor Postion Report (?) (DECXCPR)
ESC [ ? 62 n
  DSR 62 (historically: macro space)
ESC [ ? 63 ; n
  DSR 63 (historically: memory checksum)
ESC [ ? 75 n
  DSR 75 (historically: Data Integrity)
ESC [ ? 85 n
  DSR 85 (historically: Multiple Session Status)
ESC [ > n
  Disable Modifier Key Reporting Formats
ESC [ ? $ p
  Request Mode (?) (DECRQM)
ESC [ > p
  Change Mouse Pointer Auto Hide
ESC [ ! p
  Soft Reset (DECSTR) todo todo
ESC [ $ p
  Request Mode (RQM)
ESC [ [ ] # p
  Alias: Save Rendition Attributes
ESC [ + p
  ??? DECSR todo
ESC [ ; " p
  Select VT-XXX Conformance Level (DECSCL)
ESC [ q
  Load LEDs (DECLL) todo
ESC [ # q
  Alias: Restore Rendition Attributes
ESC [ " q
  Select Character Protection Attribute (DECSCA)
ESC [ q
  Select Cursor Style (DECSCUSR)
ESC [ 1 q
  Select Cursor Style Blinking Block
ESC [ 2 q
  Select Cursor Style Steady Block
ESC [ 3 q
  Select Cursor Style Blinking Underline
ESC [ 4 q
  Select Cursor Style Steady Underline
ESC [ 5 q
  Select Cursor Style Blinking Bar
ESC [ 6 q
  Select Cursor Style Steady Bar
ESC [ * q
  ??? DECSR todo
ESC [ ; r
  Set Top and Bottom Margins (DECSTBM) todo
ESC [ ? [ ] r
  Restore Mode
ESC [ ; ; ; ; [ ] $ r
  Change Attributes in Area (DECCARA)
ESC [ s
  Save Cursor [variant] (ansi.sys)
ESC [ ; s
  Set Left and Right Margin (DECSLRM)
ESC [ ? [ ] s
  Save Mode
ESC [ t
  Window operations [DISPATCH] todo
ESC [ 1 t
  Restore Terminal Window 🔧 🔧
ESC [ 10 ; t
  Alias: Maximize Terminal 🔧
ESC [ 11 t
  Report Terminal Window State 🔧
ESC [ 13 ; t
  Report Terminal Window Position 🔧
ESC [ 14 ; t
  Report Terminal Window Size in Pixels 🔧
ESC [ 15 t
  Report Screen Size in Pixels 🔧
ESC [ 16 t
  Report Cell Size in Pixels 🔧
ESC [ 18 t
  Report Terminal Size 🔧
ESC [ 19 t
  Report Screen Size 🔧
ESC [ 2 t
  Minimize Terminal Window 🔧 🔧
ESC [ 20 t
  Get Icon Title 🔧 🔧
ESC [ 21 t
  Get Terminal Title 🔧 🔧
ESC [ 22 ; t
  Push Terminal Title
ESC [ 23 ; t
  Pop Terminal Title
ESC [ 3 ; ; t
  Set Terminal Window Position 🔧 🔧
ESC [ 4 ; ; t
  Set Terminal Window Size in Pixels 🔧 🔧
ESC [ 5 t
  Raise Terminal Window 🔧 🔧
ESC [ 6 t
  Lower Terminal Window 🔧 🔧
ESC [ 7 t
  Refresh/Redraw Terminal Window 🔧
ESC [ 8 ; ; t
  Set Terminal Window Size 🔧 🔧 todo
ESC [ 9 ; t
  Maximize Terminal Window 🔧 🔧
ESC [ ? t
  Toggle Mode (?)
ESC [ > [ ] t
  Set Title Mode
ESC [ ; ; ; ; [ ] $ t
  Reverse Attributes in Area (DECRARA)
ESC [ t
  Set Warning Bell Volume (SWBV)
ESC [ u
  Restore cursor (ansi.sys)
ESC [ u
  Set Margin Bell Volume (SMBV)
ESC [ ; ; ; ; ; ; ; $ v
  Copy rectangular area (DECCRA)
ESC [ $ w
  Request Presentation State Report (DECRQPSR)
ESC [ 1 $ w
  Request Cursor Information Report (DECCIR)
ESC [ 2 $ w
  Request Tab Stop Report (DECTABSR)
ESC [ ; ; ; ' w
  DEC Locator Watch Pointer Leave 🔧
ESC [ x
  Request Terminal Parameters 🔧
ESC [ ; ; ; ; $ x
  Fill Rectangular Area (DECFRA)
ESC [ * x
  Select Attribute Change Extent (DECSACE)
ESC [ # y
  Select Checksum Extension (XTCHECKSUM) todo
ESC [ ; ; ; ; ; * y
  Request Checksum of Rectangular Area (DECRQCRA) todo todo
ESC [ ; ; ; $ z
  Erase Rectangular Area (DECERA)
ESC [ ; ' z
  DEC Locator Activate/Deactivate 🔧
ESC [ @
  Insert Blanks (ICH)
ESC [ @
  Scroll Left (SL)
ESC [ ; ]
  Linux Private Control (SETTERM)
ESC [ ^
  ??? todo
ESC [ `
  Cursor Horizontal Position Absolute (HPA)
ESC [ ; ; ; $ {
  Selective erase rectangular area (DECSERA)
ESC [ [ ] # {
  Save Rendition Attributes
ESC [ [ ] ' {
  DEC Locator Select Events 🔧
ESC [ $ |
  DEC Set Columns per Page (DECSCPP)
ESC [ ; ; ; # |
  Report Common Attributes of Rectangular Area
ESC [ * |
  DEC Select Number of Lines per Screen (DECSNLS) 🔧
ESC [ ' |
  DEC Locator Report Current Position 🔧
ESC [ # }
  Restore Rendition Attributes
ESC [ ' }
  Insert Column (DECIC)
ESC [ ' ~
  Delete Column (DECDC)
ESC P $ q $| ESC \
  Query 132 Column Mode (DECSCPP)
ESC P $ q m ESC \
  Query SGR state
ESC P $ q "p ESC \
  Query VT-xxx Conformance Level and C1 Encoding
ESC P $ q "q ESC \
  Query Character Protection Attribute
ESC P $ q r ESC \
  Query Current Top and Bottom Margins
ESC P $ q s ESC \
  Query Left and Right Margins
ESC P $ q q ESC \
  Query cursor style
ESC P $ q *| ESC \
  Report Lines
ESC P $ q t ESC \
  Report Lines (if not smaller than 25)
ESC P $ r ESC \
  (reserved for terminal to application communication)
ESC P + p ESC \
  Set Terminal Description for 'tcap' Keyboard Mapping 🔧
ESC P + q [ ] ESC \
  Query Keyboard Mapping or Miscellaneous Information 🔧
ESC P 1 $ t ; ; 1 ; ; ; ; ; ; O ; ESC \
  Restore Cursor Information Report
ESC P 2 $ t ESC \
  Restore Tab Stop Report
ESC P { ESC \
  DEC Font Download (DECDLD)
ESC P | ESC \
  DEC User Defined Keys (DECUDK)
ESC P p ESC \
  (reserved for regis graphics)
ESC P ; ; q ESC \
  (reserved for sixel graphics)
ESC ] 0 ; ESC \
  Set Window Title and Icon Name todo todo
ESC ] 1 ; ESC \
  Change Icon Name todo
ESC ] 10 ; ESC \
  Change/Read Special Text Default Foreground Color todo todo
ESC ] 104 ; ESC \
  Reset Palette Colors todo
ESC ] 105 ; ESC \
  Reset Attribute Replacement Colors todo
ESC ] 106 ; [ ; ] ESC \
  Activate/Deactivate attribute replacement colors todo
ESC ] 11 ; ESC \
  Change/Read Special Text Default Background Color todo todo
ESC ] 110 ESC \
  Reset Special Text Default Foreground Color todo
ESC ] 111 ESC \
  Reset Special Text Default Background Color todo
ESC ] 112 ESC \
  Reset Cursor Color todo
ESC ] 113 ESC \
  Reset Pointer Inlet Color
ESC ] 114 ESC \
  Reset Pointer Mask Color
ESC ] 115 ; ESC \
  OSC 115 (reserved for xterm TEK-Mode)
ESC ] 116 ; ESC \
  OSC 116 (reserved for xterm TEK-Mode)
ESC ] 117 ESC \
  Reset Selection Background Color todo
ESC ] 118 ; ESC \
  OSC 118 (reserved for xterm TEK-Mode)
ESC ] 119 ESC \
  Reset Selection Foreground Color todo
ESC ] 12 ; ESC \
  Change/Read Cursor Color todo todo
ESC ] 13 ; ESC \
  Change/Read Pointer Inlet Color
ESC ] 14 ; ESC \
  Change/Read Pointer Mask Color
ESC ] 15 ; ESC \
  OSC 15 (reserved for xterm TEK-Mode)
ESC ] 16 ; ESC \
  OSC 16 (reserved for xterm TEK-Mode)
ESC ] 17 ; ESC \
  Selection Background Color todo
ESC ] 18 ; ESC \
  OSC 18 (reserved for xterm TEK-Mode)
ESC ] 19 ; ESC \
  Change/Read Selection Foreground Color 🔧 todo
ESC ] 2 ; ESC \
  Change Window title todo todo
ESC ] 27; ESC \
  (used by other terminals)
ESC ] 28 ESC \
  (used by other terminals)
ESC ] 29 ESC \
  (used by other terminals)
ESC ] 3 ; ESC \
  Change / Delete an X11-Property 🔧
ESC ] 30 ; ESC \
  Set Session Name todo
ESC ] 31 ; ESC \
  Open Url
ESC ] 32 ; ESC \
  Set Session Icon todo
ESC ] 39 ESC \
  Alias: Change/Read Special Text Foreground Color
ESC ] 4 ; ESC \
  Change/Read palette color todo
ESC ] 46 ; ESC \
  OSC 46 (Reserved file logging)
ESC ] 49 ESC \
  Alias: Change/Read Special Text Background Color
ESC ] 5 ; ESC \
  Set Attribute Replacement Colors
ESC ] 50 ; ESC \
  osc-50_konsole todo
ESC ] 50 ; ESC \
  Change/Query Font (xterm) 🔧
ESC ] 51 ; ESC \
  OSC TODO 51
ESC ] 52 ; ; ESC \
  Set/Get Clipboard Contents 🔧
ESC ] 55 ; ESC \
  OSC TODO 55
ESC ] 6 ; ESC \
  Alias: Activate/Deactivate attribute replacement colors
ESC ] 6 ; ESC \
  OSC TODO 6 Current File todo
ESC ] 7 ; ESC \
  Report Current Working Directory todo todo
ESC ] 701 ; ESC \
  Override Terminal Locale todo
ESC ] 702;? ESC \
  Report Terminal Version
ESC ] 704 ; ESC \
  Set Replacement Color for Italic Text
ESC ] 706 ; ESC \
  Set Replacement Color for Bold Text
ESC ] 707 ; ESC \
  Set Replacement Color for Underlined Text
ESC ] 708 ; ESC \
  Set Terminal Border Color
ESC ] 710 ; ESC \
  Set Base Font
ESC ] 711 ; ESC \
  Set Bold Font
ESC ] 712 ; ESC \
  Set Italic Font
ESC ] 713 ; ESC \
  Set Bold Italic Font
ESC ] 720 ; ESC \
  Move view port towards to top of the scroll back buffer (or clear scrollback)
ESC ] 721 ; ESC \
  Move view port towards the currently active buffer (or clear scrollback)
ESC ] 777 ; ESC \
  OSC TODO 777 todo
ESC ] 8 ; ESC \
  OSC TODO 8 (hyperlink) todo
ESC ] 9 ESC \
  (used by other terminals)
ESC ] I ESC \
  Set Terminal Icon
ESC ] l ESC \
  OSC l (Alias)
ESC ] L ESC \
  OSC L (Alias)
ESC ] P
  Linux Palette Set
ESC ] R
  Linux Palette Reset
ESC ^ ESC \
  (used by other terminals)

Additionally there are character set definition sequences that follow a distinct pattern. These sequences should not used in UTF-8 mode by applications but only in traditional 7 or 8 bit ISO-2022 mode.

Many applications still use DEC_Spec_Graphic ('0') instead of the corresponding unicode codepoints for line drawing characters.

Sequence shapeSelect Characterset Result
ESC ( rest-> Setup G0 charset with 94 characters
ESC ) rest-> Setup G1 charset with 94 characters
ESC * rest-> Setup G2 charset with 94 characters
ESC + rest-> Setup G3 charset with 94 characters
ESC - rest96-> Setup G1 charset 96 characters
ESC . rest96-> Setup G2 charset 96 characters
ESC / rest96-> Setup G3 charset 96 characters

Where rest is:

restCharacter set
BASCII
ABritish
0DEC Special Character and Line Drawing Set
1DEC_Alt_Chars
2DEC_Alt_Graphics
<DEC_Supp
4Dutch
5Finnish
CFinnish2
RFrench
fFrench2
QFrench_Canadian
KGerman (linuxvc: user defined mapping)
YItalian
ENorwegian_Danish2
6Norwegian_Danish3
ZSpanish
7Swedish
HSwedish2
=Swiss
ABritish_Latin_1,
>DEC_Technical
9French_Canadian2
`Norwegian_Danish
%5DEC_Supp_Graphic
% 6Portugese
% 0Turkish
% 2Turkish Supplement
% 3no change?
% =Hebrew
"4DEC Hebrew Supplement
">Greek
"?DEC Greek Supplement
UIBM code page 437 (linuxvc only)

Where rest96 is:

rest96Character set
ALatin-1 Supplemental
FGreek (Bottom part of ISO-8859-7)
HHebrew (Bottom part of ISO-8859-8)
LLatin-Cyrillic (Bottom part of ISO-8859-5)
MLatin-5 (Bottom part of ISO-8859-9)

See https://github.com/ThomasDickey/xterm-snapshots/blob/master/charsets.c and "Digital ANSI-Compliant Printing Protocol Level 2 Programming Reference Manual EK–PPLV2–PM. B01" for detailed character mapping tables.