1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="Hugo 0.108.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="garhve" />
<meta property="og:url" content="https://blog.garhve.com/posts/5/" />
<link rel="canonical" href="https://blog.garhve.com/posts/5/" /><link rel="apple-touch-icon" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" />
<link rel="icon" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" />
<link rel="shortcut" href="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /><link rel="alternate" type="application/atom+xml" href="https://blog.garhve.comindex.xml" title="blog | garhve's hub">
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https:\/\/blog.garhve.com"
},
"articleSection" : "posts",
"name" : "Escape Sequences",
"headline" : "Escape Sequences",
"description" : "copied from github in case one day it disappears\nmore information could visit vt100 User Guide\nANSI Escape Sequences Standard escape codes are prefixed with Escape:\nCtrl-Key: ^[ Octal: \\033 Unicode: \\u001b Hexadecimal: \\x1B Decimal: 27 Followed by the command, somtimes delimited by opening square bracket ([), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.\nArguments are delimeted by semi colon (;).",
"inLanguage" : "en-US",
"author" : "garhve",
"creator" : "garhve",
"publisher": "garhve",
"accountablePerson" : "garhve",
"copyrightHolder" : "garhve",
"copyrightYear" : "2022",
"datePublished": "2022-09-12 09:02:06 \u002b0800 CST",
"dateModified" : "2022-09-12 09:02:06 \u002b0800 CST",
"url" : "https:\/\/blog.garhve.com\/posts\/5\/",
"keywords" : [ ]
}
</script>
<title>Escape Sequences</title>
<meta property="og:title" content="Escape Sequences" />
<meta property="og:type" content="article" />
<meta property="og:description" content="copied from github in case one day it disappears
more information could visit vt100 User Guide
ANSI Escape Sequences Standard escape codes are prefixed with Escape:
Ctrl-Key: ^[ Octal: \033 Unicode: \u001b Hexadecimal: \x1B Decimal: 27 Followed by the command, somtimes delimited by opening square bracket ([), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.
Arguments are delimeted by semi colon (;)." />
<meta name="description" content="copied from github in case one day it disappears
more information could visit vt100 User Guide
ANSI Escape Sequences Standard escape codes are prefixed with Escape:
Ctrl-Key: ^[ Octal: \033 Unicode: \u001b Hexadecimal: \x1B Decimal: 27 Followed by the command, somtimes delimited by opening square bracket ([), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.
Arguments are delimeted by semi colon (;)." />
<meta property="og:locale" content="en-us" /><meta property="og:image" content="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" />
<style>@font-face{font-family:ssbb;src:url(/fonts/ssbb.ttf)format('truetype');font-weight:400;font-style:normal}body{font-family:bree serif,ssbb,sans-serif;-webkit-font-smoothing:antialiased;margin:0 20px}article{max-width:800px;margin-left:auto;margin-right:auto}a{color:#000;text-decoration:none}a:hover{font-weight:600;text-decoration:underline}.post-ads{margin:50px 0}.markdown-body{font-size:16px;max-width:100%}.markdown-body a{text-decoration:underline;text-decoration-color:#000}.markdown-body blockquote{margin:0;padding:0 1em;color:#57606a;border-left:.25em solid #d0d7de}.markdown-body pre{padding:16px;overflow:auto;border-radius:10px}.markdown-body code{padding:.2em .4em;font-size:85%;background-color:inherit;border-radius:6px;font-family:fira code,monospace}.markdown-body pre>code{padding:0;font-size:80%;background-color:inherit;border:0;font-family:fira code,monospace}.Chinese .markdown-body{line-height:200%}.site-date-catalog{font-size:2rem}.header-title{font-size:2rem;font-weight:700;margin-top:32px;font-family:bungee shade,sans-serif}.header-title a{text-decoration:none}.header-subtitle{color:#666}.header-items{margin:10px 0}.header-item{margin:0 5px}.header-line{width:100%;border-width:2px;border-color:#482936;border-style:solid none none none}.lang-switch{font-weight:600}#posts-list{min-height:600px}.posts-line{font-size:1.2rem;margin:12px 0}.posts-categories{font-size:.8rem;margin:auto;text-align:center}.posts-category{padding:3px 0;border:#000 2px solid;border-radius:5px}.site-footer{margin-top:50px}.site-footer-item{margin-right:12px}.post-content img{max-width:100%;display:block;margin-right:auto;margin-top:12px}.post-header{margin-bottom:50px}.post-title{font-size:2rem;font-weight:600}.post-tags{display:inline;font-weight:600;padding:2px 5px;margin-right:6px;border:#000 2px solid;border-radius:5px}.post-date{font-weight:800;font-style:italic}.post-author{float:right;font-weight:600}.page-content{min-height:60%}.post-content{margin-bottom:50px}.post-content p{hyphens:auto;line-height:1.8;text-justify:ideographic;margin-bottom:1em}.related-content{border-width:3px;border-style:solid;border-color:#000;padding:0 10px;margin-bottom:50px;margin-top:100px}.related-content li{margin:5px 0}.taxonomy-term{font-size:3rem}.gallery-img{text-align:center}.gallery-img span{text-align:center}.gallery-img-desc{font-size:.8em;font-weight:800}#disqus_thread{position:relative}#disqus_thread:after{content:"";display:block;height:55px;width:100%;position:absolute;bottom:0;background:#fff}@media screen and (max-width:600px){.header-title,.header-subtitle,.header-items{text-align:center}.posts-line{font-size:16px}.markdown-body{font-size:16px}.post-title{font-size:2rem}.post-content p{letter-spacing:.05em}}@media screen and (max-width:48em){.posts-category{display:none}}</style>
<style>.container,.container-fluid{margin-right:auto;margin-left:auto}.container-fluid{padding-right:2rem;padding-left:2rem}.row{box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-flex:0;-ms-flex:0 1 auto;flex:initial;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:-.5rem;margin-left:-.5rem}.row.reverse{-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse}.col.reverse{-webkit-box-orient:vertical;-webkit-box-direction:reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.col-xs,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-offset-0,.col-xs-offset-1,.col-xs-offset-10,.col-xs-offset-11,.col-xs-offset-12,.col-xs-offset-2,.col-xs-offset-3,.col-xs-offset-4,.col-xs-offset-5,.col-xs-offset-6,.col-xs-offset-7,.col-xs-offset-8,.col-xs-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-xs{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-xs-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-xs-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-xs-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-xs-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-xs-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-xs-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-xs-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-xs-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-xs-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-xs-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-xs-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-xs-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-xs-offset-0{margin-left:0}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-11{margin-left:91.66666667%}.start-xs{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-xs{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-xs{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-xs{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-xs{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-xs{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-xs{-ms-flex-pack:distribute;justify-content:space-around}.between-xs{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-xs{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-xs{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}@media only screen and (min-width:48em){.container{width:49rem}.col-sm,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-offset-0,.col-sm-offset-1,.col-sm-offset-10,.col-sm-offset-11,.col-sm-offset-12,.col-sm-offset-2,.col-sm-offset-3,.col-sm-offset-4,.col-sm-offset-5,.col-sm-offset-6,.col-sm-offset-7,.col-sm-offset-8,.col-sm-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-sm{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-sm-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-sm-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-sm-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-sm-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-sm-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-sm-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-sm-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-sm-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-sm-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-sm-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-sm-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-sm-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-sm-offset-0{margin-left:0}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-11{margin-left:91.66666667%}.start-sm{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-sm{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-sm{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-sm{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-sm{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-sm{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-sm{-ms-flex-pack:distribute;justify-content:space-around}.between-sm{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-sm{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-sm{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}@media only screen and (min-width:64em){.container{width:65rem}.col-md,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-offset-0,.col-md-offset-1,.col-md-offset-10,.col-md-offset-11,.col-md-offset-12,.col-md-offset-2,.col-md-offset-3,.col-md-offset-4,.col-md-offset-5,.col-md-offset-6,.col-md-offset-7,.col-md-offset-8,.col-md-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-md{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-md-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-md-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-md-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-md-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-md-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-md-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-md-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-md-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-md-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-md-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-md-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-md-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-md-offset-0{margin-left:0}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-3{margin-left:25%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-6{margin-left:50%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-9{margin-left:75%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-11{margin-left:91.66666667%}.start-md{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-md{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-md{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-md{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-md{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-md{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-md{-ms-flex-pack:distribute;justify-content:space-around}.between-md{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-md{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-md{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}@media only screen and (min-width:75em){.container{width:76rem}.col-lg,.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-offset-0,.col-lg-offset-1,.col-lg-offset-10,.col-lg-offset-11,.col-lg-offset-12,.col-lg-offset-2,.col-lg-offset-3,.col-lg-offset-4,.col-lg-offset-5,.col-lg-offset-6,.col-lg-offset-7,.col-lg-offset-8,.col-lg-offset-9{box-sizing:border-box;-webkit-box-flex:0;-ms-flex:0 0 auto;flex:none;padding-right:.5rem;padding-left:.5rem}.col-lg{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;-ms-flex-preferred-size:0;flex-basis:0;max-width:100%}.col-lg-1{-ms-flex-preferred-size:8.33333333%;flex-basis:8.33333333%;max-width:8.33333333%}.col-lg-2{-ms-flex-preferred-size:16.66666667%;flex-basis:16.66666667%;max-width:16.66666667%}.col-lg-3{-ms-flex-preferred-size:25%;flex-basis:25%;max-width:25%}.col-lg-4{-ms-flex-preferred-size:33.33333333%;flex-basis:33.33333333%;max-width:33.33333333%}.col-lg-5{-ms-flex-preferred-size:41.66666667%;flex-basis:41.66666667%;max-width:41.66666667%}.col-lg-6{-ms-flex-preferred-size:50%;flex-basis:50%;max-width:50%}.col-lg-7{-ms-flex-preferred-size:58.33333333%;flex-basis:58.33333333%;max-width:58.33333333%}.col-lg-8{-ms-flex-preferred-size:66.66666667%;flex-basis:66.66666667%;max-width:66.66666667%}.col-lg-9{-ms-flex-preferred-size:75%;flex-basis:75%;max-width:75%}.col-lg-10{-ms-flex-preferred-size:83.33333333%;flex-basis:83.33333333%;max-width:83.33333333%}.col-lg-11{-ms-flex-preferred-size:91.66666667%;flex-basis:91.66666667%;max-width:91.66666667%}.col-lg-12{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}.col-lg-offset-0{margin-left:0}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-11{margin-left:91.66666667%}.start-lg{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:start}.center-lg{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;text-align:center}.end-lg{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;text-align:end}.top-lg{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start}.middle-lg{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.bottom-lg{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end}.around-lg{-ms-flex-pack:distribute;justify-content:space-around}.between-lg{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.first-lg{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1}.last-lg{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}}</style>
<link href="/index.xml" rel="alternate" type="application/rss+xml"
title="blog | garhve's hub">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Bree+Serif|Bungee+Shade|ZCOOL+KuaiLe" rel="stylesheet">
</head>
<body>
<article class="post English" id="article">
<div class="row">
<div class="col-xs-12">
<div class="site-header">
<header>
<div class="header-title">
<a href="/"
>Garhve</a
>
</div>
<div class="header-subtitle"></div>
</header>
<div class="row end-md center-xs header-items">
</div>
<div class="row end-xs">
<div class="lang-switch col-xs-3 col-xs-offset-9">
<a href="/cn/">Chinese</a>
</div>
</div>
<div class="header-line"></div>
</div>
<header class="post-header">
<h1 class="post-title">Escape Sequences</h1>
<div class="row post-desc">
<div class="col-xs-6">
<time class="post-date" datetime="2022-09-12 09:02:06 CST">
12 Sep 2022
</time>
</div>
<div class="col-xs-6">
<div class="post-author">
<a target="_blank" href="https://garhve.com">@garhve</a>
</div>
</div>
</div>
</header>
<div class="post-content markdown-body">
<blockquote>
<p>copied from <a href="https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797">github</a> in case one day it disappears</p>
<p>more information could visit <a href="https://vt100.net/docs/vt100-ug/chapter3.html">vt100 User Guide</a></p>
</blockquote>
<h1 id="ansi-escape-sequences">ANSI Escape Sequences</h1>
<p>Standard escape codes are prefixed with <code>Escape</code>:</p>
<ul>
<li>Ctrl-Key: <code>^[</code></li>
<li>Octal: <code>\033</code></li>
<li>Unicode: <code>\u001b</code></li>
<li>Hexadecimal: <code>\x1B</code></li>
<li>Decimal: <code>27</code></li>
</ul>
<p>Followed by the command, somtimes delimited by opening square bracket (<code>[</code>), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.</p>
<p>Arguments are delimeted by semi colon (<code>;</code>).</p>
<p>For example:</p>
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[1;31m <span style="font-style:italic"># Set style to bold, red foreground.</span>
</span></span></code></pre></div><h2 id="sequences">Sequences</h2>
<ul>
<li><code>ESC</code> - sequence starting with <code>ESC</code> (<code>\x1B</code>)</li>
<li><code>CSI</code> - Control Sequence Introducer: sequence starting with <code>ESC [</code> or CSI (<code>\x9B</code>)</li>
<li><code>DCS</code> - Device Control String: sequence starting with <code>ESC P</code> or DCS (<code>\x90</code>)</li>
<li><code>OSC</code> - Operating System Command: sequence starting with <code>ESC ]</code> or OSC (<code>\x9D</code>)</li>
</ul>
<p>Any whitespaces between sequences and arguments should be ignored. They are present for improved readability.</p>
<h2 id="general-ascii-codes">General ASCII Codes</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>decimal</th>
<th>octal</th>
<th>hex</th>
<th>C-escape</th>
<th>Ctrl-Key</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>BEL</code></td>
<td>7</td>
<td>007</td>
<td>0x07</td>
<td><code>\a</code></td>
<td><code>^G</code></td>
<td>Terminal bell</td>
</tr>
<tr>
<td><code>BS</code></td>
<td>8</td>
<td>010</td>
<td>0x08</td>
<td><code>\b</code></td>
<td><code>^H</code></td>
<td>Backspace</td>
</tr>
<tr>
<td><code>HT</code></td>
<td>9</td>
<td>011</td>
<td>0x09</td>
<td><code>\t</code></td>
<td><code>^I</code></td>
<td>Horizontal TAB</td>
</tr>
<tr>
<td><code>LF</code></td>
<td>10</td>
<td>012</td>
<td>0x0A</td>
<td><code>\n</code></td>
<td><code>^J</code></td>
<td>Linefeed (newline)</td>
</tr>
<tr>
<td><code>VT</code></td>
<td>11</td>
<td>013</td>
<td>0x0B</td>
<td><code>\v</code></td>
<td><code>^K</code></td>
<td>Vertical TAB</td>
</tr>
<tr>
<td><code>FF</code></td>
<td>12</td>
<td>014</td>
<td>0x0C</td>
<td><code>\f</code></td>
<td><code>^L</code></td>
<td>Formfeed (also: New page<code>NP</code>)</td>
</tr>
<tr>
<td><code>CR</code></td>
<td>13</td>
<td>015</td>
<td>0x0D</td>
<td><code>\r</code></td>
<td><code>^M</code></td>
<td>Carriage return</td>
</tr>
<tr>
<td><code>ESC</code></td>
<td>27</td>
<td>033</td>
<td>0x1B</td>
<td><code>\e</code><a href="#escape">*</a></td>
<td><code>^[</code></td>
<td>Escape character</td>
</tr>
<tr>
<td><code>DEL</code></td>
<td>127</td>
<td>177</td>
<td>0x7F</td>
<td><code><none></code></td>
<td><code><none></code></td>
<td>Delete character</td>
</tr>
</tbody>
</table>
<div id="escape"></div>
<blockquote>
<p><strong>Note:</strong> Some control escape sequences, like <code>\e</code> for <code>ESC</code>, are not guaranteed to work in all languages and compilers. It is recommended to use the decimal, octal or hex representation as escape code.</p>
</blockquote>
<blockquote>
<p><strong>Note:</strong> The <strong>Ctrl-Key</strong> representation is simply associating the non-printable characters from ASCII code 1 with the printable (letter) characters from ASCII code 65 (“A”). ASCII code 1 would be <code>^A</code> (Ctrl-A), while ASCII code 7 (BEL) would be <code>^G</code> (Ctrl-G). This is a common representation (and input method) and historically comes from one of the VT series of terminals.</p>
</blockquote>
<h2 id="cursor-controls">Cursor Controls</h2>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[H</code></td>
<td style="text-align:left">moves cursor to home position (0, 0)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[{line};{column}H</code> <br> <code>ESC[{line};{column}f</code></td>
<td style="text-align:left">moves cursor to line #, column #</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#A</code></td>
<td style="text-align:left">moves cursor up # lines</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#B</code></td>
<td style="text-align:left">moves cursor down # lines</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#C</code></td>
<td style="text-align:left">moves cursor right # columns</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#D</code></td>
<td style="text-align:left">moves cursor left # columns</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#E</code></td>
<td style="text-align:left">moves cursor to beginning of next line, # lines down</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#F</code></td>
<td style="text-align:left">moves cursor to beginning of previous line, # lines up</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[#G</code></td>
<td style="text-align:left">moves cursor to column #</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[6n</code></td>
<td style="text-align:left">request cursor position (reports as<code>ESC[#;#R</code>)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC M</code></td>
<td style="text-align:left">moves cursor one line up, scrolling if needed</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC 7</code></td>
<td style="text-align:left">save cursor position (DEC)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC 8</code></td>
<td style="text-align:left">restores the cursor to the last saved position (DEC)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[s</code></td>
<td style="text-align:left">save cursor position (SCO)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[u</code></td>
<td style="text-align:left">restores the cursor to the last saved position (SCO)</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>Note:</strong> Some sequences, like saving and restoring cursors, are private sequences and are not standardized. While some terminal emulators (i.e. xterm and derived) support both SCO and DEC sequences, they are likely to have different functionality. It is therefore recommended to use DEC sequences.</p>
</blockquote>
<h2 id="erase-functions">Erase Functions</h2>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[J</code></td>
<td style="text-align:left">erase in display (same as ESC[0J)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[0J</code></td>
<td style="text-align:left">erase from cursor until end of screen</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[1J</code></td>
<td style="text-align:left">erase from cursor to beginning of screen</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[2J</code></td>
<td style="text-align:left">erase entire screen</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[3J</code></td>
<td style="text-align:left">erase saved lines</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[K</code></td>
<td style="text-align:left">erase in line (same as ESC[0K)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[0K</code></td>
<td style="text-align:left">erase from cursor to end of line</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[1K</code></td>
<td style="text-align:left">erase start of line to the cursor</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[2K</code></td>
<td style="text-align:left">erase the entire line</td>
</tr>
</tbody>
</table>
<blockquote>
<p>Note: Erasing the line won’t move the cursor, meaning that the cursor will stay at the last position it was at before the line was erased. You can use <code>\r</code> after erasing the line, to return the cursor to the start of the current line.</p>
</blockquote>
<h2 id="colors--graphics-mode">Colors / Graphics Mode</h2>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Reset Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[1;34;{...}m</code></td>
<td style="text-align:left"></td>
<td style="text-align:left">Set graphics modes for cell, separated by semicolon (<code>;</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[0m</code></td>
<td style="text-align:left"></td>
<td style="text-align:left">reset all modes (styles and colors)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[1m</code></td>
<td style="text-align:left"><code>ESC[22m</code></td>
<td style="text-align:left">set bold mode.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[2m</code></td>
<td style="text-align:left"><code>ESC[22m</code></td>
<td style="text-align:left">set dim/faint mode.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[3m</code></td>
<td style="text-align:left"><code>ESC[23m</code></td>
<td style="text-align:left">set italic mode.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[4m</code></td>
<td style="text-align:left"><code>ESC[24m</code></td>
<td style="text-align:left">set underline mode.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[5m</code></td>
<td style="text-align:left"><code>ESC[25m</code></td>
<td style="text-align:left">set blinking mode</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[7m</code></td>
<td style="text-align:left"><code>ESC[27m</code></td>
<td style="text-align:left">set inverse/reverse mode</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[8m</code></td>
<td style="text-align:left"><code>ESC[28m</code></td>
<td style="text-align:left">set hidden/invisible mode</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[9m</code></td>
<td style="text-align:left"><code>ESC[29m</code></td>
<td style="text-align:left">set strikethrough mode.</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>Note:</strong> Some terminals may not support some of the graphic mode sequences listed above.</p>
</blockquote>
<blockquote>
<p><strong>Note:</strong> Both dim and bold modes are reset with the <code>ESC[22m</code> sequence. The <code>ESC[21m</code> sequence is a non-specified sequence for double underline mode and only work in some terminals and is reset with <code>ESC[24m</code>.</p>
</blockquote>
<h3 id="color-codes">Color codes</h3>
<p>Most terminals support 8 and 16 colors, as well as 256 (8-bit) colors. These colors are set by the user, but have commonly defined meanings.</p>
<h4 id="8-16-colors">8-16 Colors</h4>
<table>
<thead>
<tr>
<th style="text-align:left">Color Name</th>
<th style="text-align:left">Foreground Color Code</th>
<th style="text-align:left">Background Color Code</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Black</td>
<td style="text-align:left"><code>30</code></td>
<td style="text-align:left"><code>40</code></td>
</tr>
<tr>
<td style="text-align:left">Red</td>
<td style="text-align:left"><code>31</code></td>
<td style="text-align:left"><code>41</code></td>
</tr>
<tr>
<td style="text-align:left">Green</td>
<td style="text-align:left"><code>32</code></td>
<td style="text-align:left"><code>42</code></td>
</tr>
<tr>
<td style="text-align:left">Yellow</td>
<td style="text-align:left"><code>33</code></td>
<td style="text-align:left"><code>43</code></td>
</tr>
<tr>
<td style="text-align:left">Blue</td>
<td style="text-align:left"><code>34</code></td>
<td style="text-align:left"><code>44</code></td>
</tr>
<tr>
<td style="text-align:left">Magenta</td>
<td style="text-align:left"><code>35</code></td>
<td style="text-align:left"><code>45</code></td>
</tr>
<tr>
<td style="text-align:left">Cyan</td>
<td style="text-align:left"><code>36</code></td>
<td style="text-align:left"><code>46</code></td>
</tr>
<tr>
<td style="text-align:left">White</td>
<td style="text-align:left"><code>37</code></td>
<td style="text-align:left"><code>47</code></td>
</tr>
<tr>
<td style="text-align:left">Default</td>
<td style="text-align:left"><code>39</code></td>
<td style="text-align:left"><code>49</code></td>
</tr>
<tr>
<td style="text-align:left">Reset</td>
<td style="text-align:left"><code>0</code></td>
<td style="text-align:left"><code>0</code></td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>Note:</strong> the <em>Reset</em> color is the reset code that resets <em>all</em> colors and text effects, Use <em>Default</em> color to reset colors only.</p>
</blockquote>
<p>Most terminals, apart from the basic set of 8 colors, also support the “bright” or “bold” colors. These have their own set of codes, mirroring the normal colors, but with an additional <code>;1</code> in their codes:</p>
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-style:italic"># Set style to bold, red foreground.</span>
</span></span><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[1;31mHello
</span></span><span style="display:flex;"><span><span style="font-style:italic"># Set style to dimmed white foreground with red background.</span>
</span></span><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[2;37;41mWorld
</span></span></code></pre></div><p>Terminals that support the <a href="https://sites.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/cmds/aixcmds1/aixterm.htm">aixterm specification</a> provides bright versions of the ISO colors, without the need to use the bold modifier:</p>
<table>
<thead>
<tr>
<th style="text-align:left">Color Name</th>
<th style="text-align:left">Foreground Color Code</th>
<th style="text-align:left">Background Color Code</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Bright Black</td>
<td style="text-align:left"><code>90</code></td>
<td style="text-align:left"><code>100</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Red</td>
<td style="text-align:left"><code>91</code></td>
<td style="text-align:left"><code>101</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Green</td>
<td style="text-align:left"><code>92</code></td>
<td style="text-align:left"><code>102</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Yellow</td>
<td style="text-align:left"><code>93</code></td>
<td style="text-align:left"><code>103</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Blue</td>
<td style="text-align:left"><code>94</code></td>
<td style="text-align:left"><code>104</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Magenta</td>
<td style="text-align:left"><code>95</code></td>
<td style="text-align:left"><code>105</code></td>
</tr>
<tr>
<td style="text-align:left">Bright Cyan</td>
<td style="text-align:left"><code>96</code></td>
<td style="text-align:left"><code>106</code></td>
</tr>
<tr>
<td style="text-align:left">Bright White</td>
<td style="text-align:left"><code>97</code></td>
<td style="text-align:left"><code>107</code></td>
</tr>
</tbody>
</table>
<h4 id="256-colors">256 Colors</h4>
<p>The following escape codes tells the terminal to use the given color ID:</p>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[38;5;{ID}m</code></td>
<td style="text-align:left">Set foreground color.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[48;5;{ID}m</code></td>
<td style="text-align:left">Set background color.</td>
</tr>
</tbody>
</table>
<p>Where <code>{ID}</code> should be replaced with the color index from 0 to 255 of the following color table:</p>
<p><img src="https://user-images.githubusercontent.com/995050/47952855-ecb12480-df75-11e8-89d4-ac26c50e80b9.png" alt="256 Color table"></p>
<p>The table starts with the original 16 colors (0-15).</p>
<p>The proceeding 216 colors (16-231) or formed by a 3bpc RGB value offset by 16, packed into a single value.</p>
<p>The final 24 colors (232-255) are grayscale starting from a shade slighly lighter than black, ranging up to shade slightly darker than white.</p>
<p>Some emulators interpret these steps as linear increments (<code>256 / 24</code>) on all three channels, although some emulators may explicitly define these values.</p>
<h4 id="rgb-colors">RGB Colors</h4>
<p>More modern terminals supports <a href="https://en.wikipedia.org/wiki/Color_depth#True_color_.2824-bit.29">Truecolor</a> (24-bit RGB), which allows you to set foreground and background colors using RGB.</p>
<p>These escape sequences are usually not well documented.</p>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[38;2;{r};{g};{b}m</code></td>
<td style="text-align:left">Set foreground color as RGB.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[48;2;{r};{g};{b}m</code></td>
<td style="text-align:left">Set background color as RGB.</td>
</tr>
</tbody>
</table>
<blockquote>
<p>Note that <code>;38</code> and <code>;48</code> corresponds to the 16 color sequence and is interpreted by the terminal to set the foreground and background color respectively. Where as <code>;2</code> and <code>;5</code> sets the color format.</p>
</blockquote>
<h2 id="screen-modes">Screen Modes</h2>
<h3 id="set-mode">Set Mode</h3>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[={value}h</code></td>
<td style="text-align:left">Changes the screen width or type to the mode specified by value.</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=0h</code></td>
<td style="text-align:left">40 x 25 monochrome (text)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=1h</code></td>
<td style="text-align:left">40 x 25 color (text)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=2h</code></td>
<td style="text-align:left">80 x 25 monochrome (text)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=3h</code></td>
<td style="text-align:left">80 x 25 color (text)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=4h</code></td>
<td style="text-align:left">320 x 200 4-color (graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=5h</code></td>
<td style="text-align:left">320 x 200 monochrome (graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=6h</code></td>
<td style="text-align:left">640 x 200 monochrome (graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=7h</code></td>
<td style="text-align:left">Enables line wrapping</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=13h</code></td>
<td style="text-align:left">320 x 200 color (graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=14h</code></td>
<td style="text-align:left">640 x 200 color (16-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=15h</code></td>
<td style="text-align:left">640 x 350 monochrome (2-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=16h</code></td>
<td style="text-align:left">640 x 350 color (16-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=17h</code></td>
<td style="text-align:left">640 x 480 monochrome (2-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=18h</code></td>
<td style="text-align:left">640 x 480 color (16-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[=19h</code></td>
<td style="text-align:left">320 x 200 color (256-color graphics)</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[={value}l</code></td>
<td style="text-align:left">Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.</td>
</tr>
</tbody>
</table>
<h3 id="common-private-modes">Common Private Modes</h3>
<p>These are some examples of private modes, which are not defined by the specification, but are implemented in most terminals.</p>
<table>
<thead>
<tr>
<th style="text-align:left">ESC Code Sequence</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>ESC[?25l</code></td>
<td style="text-align:left">make cursor invisible</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[?25h</code></td>
<td style="text-align:left">make cursor visible</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[?47l</code></td>
<td style="text-align:left">restore screen</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[?47h</code></td>
<td style="text-align:left">save screen</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[?1049h</code></td>
<td style="text-align:left">enables the alternative buffer</td>
</tr>
<tr>
<td style="text-align:left"><code>ESC[?1049l</code></td>
<td style="text-align:left">disables the alternative buffer</td>
</tr>
</tbody>
</table>
<p>Refer to the <a href="https://invisible-island.net/xterm/ctlseqs/ctlseqs.html">XTerm Control Sequences</a> for a more in-depth list of private modes defined by XTerm.</p>
<blockquote>
<p>Note: While these modes may be supported by the most terminals, some may not work in multiplexers like tmux.</p>
</blockquote>
<h3 id="keyboard-strings">Keyboard Strings</h3>
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ESC[{code};{string};{...}p
</span></span></code></pre></div><p>Redefines a keyboard key to a specified string.</p>
<p>The parameters for this escape sequence are defined as follows:</p>
<ul>
<li><code>code</code> is one or more of the values listed in the following table. These values represent keyboard keys and key combinations. When using these values in a command, you must type the semicolons shown in this table in addition to the semicolons required by the escape sequence. The codes in parentheses are not available on some keyboards. <code>ANSI.SYS</code> will not interpret the codes in parentheses for those keyboards unless you specify the <code>/X</code> switch in the <code>DEVICE</code> command for <code>ANSI.SYS</code>.</li>
<li><code>string</code> is either the ASCII code for a single character or a string contained in quotation marks. For example, both 65 and “A” can be used to represent an uppercase A.</li>
</ul>
<blockquote>
<p><strong>IMPORTANT:</strong> Some of the values in the following table are not valid for all computers. Check your computer’s documentation for values that are different.</p>
</blockquote>
<h4 id="list-of-keyboard-strings">List of keyboard strings</h4>
<table>
<thead>
<tr>
<th>Key</th>
<th>Code</th>
<th>SHIFT+code</th>
<th>CTRL+code</th>
<th>ALT+code</th>
</tr>
</thead>
<tbody>
<tr>
<td>F1</td>
<td>0;59</td>
<td>0;84</td>
<td>0;94</td>
<td>0;104</td>
</tr>
<tr>
<td>F2</td>
<td>0;60</td>
<td>0;85</td>
<td>0;95</td>
<td>0;105</td>
</tr>
<tr>
<td>F3</td>
<td>0;61</td>
<td>0;86</td>
<td>0;96</td>
<td>0;106</td>
</tr>
<tr>
<td>F4</td>
<td>0;62</td>
<td>0;87</td>
<td>0;97</td>
<td>0;107</td>
</tr>
<tr>
<td>F5</td>
<td>0;63</td>
<td>0;88</td>
<td>0;98</td>
<td>0;108</td>
</tr>
<tr>
<td>F6</td>
<td>0;64</td>
<td>0;89</td>
<td>0;99</td>
<td>0;109</td>
</tr>
<tr>
<td>F7</td>
<td>0;65</td>
<td>0;90</td>
<td>0;100</td>
<td>0;110</td>
</tr>
<tr>
<td>F8</td>
<td>0;66</td>
<td>0;91</td>
<td>0;101</td>
<td>0;111</td>
</tr>
<tr>
<td>F9</td>
<td>0;67</td>
<td>0;92</td>
<td>0;102</td>
<td>0;112</td>
</tr>
<tr>
<td>F10</td>
<td>0;68</td>
<td>0;93</td>
<td>0;103</td>
<td>0;113</td>
</tr>
<tr>
<td>F11</td>
<td>0;133</td>
<td>0;135</td>
<td>0;137</td>
<td>0;139</td>
</tr>
<tr>
<td>F12</td>
<td>0;134</td>
<td>0;136</td>
<td>0;138</td>
<td>0;140</td>
</tr>
<tr>
<td>HOME (num keypad)</td>
<td>0;71</td>
<td>55</td>
<td>0;119</td>
<td>--</td>
</tr>
<tr>
<td>UP ARROW (num keypad)</td>
<td>0;72</td>
<td>56</td>
<td>(0;141)</td>
<td>--</td>
</tr>
<tr>
<td>PAGE UP (num keypad)</td>
<td>0;73</td>
<td>57</td>
<td>0;132</td>
<td>--</td>
</tr>
<tr>
<td>LEFT ARROW (num keypad)</td>
<td>0;75</td>
<td>52</td>
<td>0;115</td>
<td>--</td>
</tr>
<tr>
<td>RIGHT ARROW (num keypad)</td>
<td>0;77</td>
<td>54</td>
<td>0;116</td>
<td>--</td>
</tr>
<tr>
<td>END (num keypad)</td>
<td>0;79</td>
<td>49</td>
<td>0;117</td>
<td>--</td>
</tr>
<tr>
<td>DOWN ARROW (num keypad)</td>
<td>0;80</td>
<td>50</td>
<td>(0;145)</td>
<td>--</td>
</tr>
<tr>
<td>PAGE DOWN (num keypad)</td>
<td>0;81</td>
<td>51</td>
<td>0;118</td>
<td>--</td>
</tr>
<tr>
<td>INSERT (num keypad)</td>
<td>0;82</td>
<td>48</td>
<td>(0;146)</td>
<td>--</td>
</tr>
<tr>
<td>DELETE (num keypad)</td>
<td>0;83</td>
<td>46</td>
<td>(0;147)</td>
<td>--</td>
</tr>
<tr>
<td>HOME</td>
<td>(224;71)</td>
<td>(224;71)</td>
<td>(224;119)</td>
<td>(224;151)</td>
</tr>
<tr>
<td>UP ARROW</td>
<td>(224;72)</td>
<td>(224;72)</td>
<td>(224;141)</td>
<td>(224;152)</td>
</tr>
<tr>
<td>PAGE UP</td>
<td>(224;73)</td>
<td>(224;73)</td>
<td>(224;132)</td>
<td>(224;153)</td>
</tr>
<tr>
<td>LEFT ARROW</td>
<td>(224;75)</td>
<td>(224;75)</td>
<td>(224;115)</td>
<td>(224;155)</td>
</tr>
<tr>
<td>RIGHT ARROW</td>
<td>(224;77)</td>
<td>(224;77)</td>
<td>(224;116)</td>
<td>(224;157)</td>
</tr>
<tr>
<td>END</td>
<td>(224;79)</td>
<td>(224;79)</td>
<td>(224;117)</td>
<td>(224;159)</td>
</tr>
<tr>
<td>DOWN ARROW</td>
<td>(224;80)</td>
<td>(224;80)</td>
<td>(224;145)</td>
<td>(224;154)</td>
</tr>
<tr>
<td>PAGE DOWN</td>
<td>(224;81)</td>
<td>(224;81)</td>
<td>(224;118)</td>
<td>(224;161)</td>
</tr>
<tr>
<td>INSERT</td>
<td>(224;82)</td>
<td>(224;82)</td>
<td>(224;146)</td>
<td>(224;162)</td>
</tr>
<tr>
<td>DELETE</td>
<td>(224;83)</td>
<td>(224;83)</td>
<td>(224;147)</td>
<td>(224;163)</td>
</tr>
<tr>
<td>PRINT SCREEN</td>
<td>--</td>
<td>--</td>
<td>0;114</td>
<td>--</td>
</tr>
<tr>
<td>PAUSE/BREAK</td>
<td>--</td>
<td>--</td>
<td>0;0</td>
<td>--</td>
</tr>
<tr>
<td>BACKSPACE</td>
<td>8</td>
<td>8</td>
<td>127</td>
<td>(0)</td>
</tr>
<tr>
<td>ENTER</td>
<td>13</td>
<td>--</td>
<td>10</td>
<td>(0</td>
</tr>
<tr>
<td>TAB</td>
<td>9</td>
<td>0;15</td>
<td>(0;148)</td>
<td>(0;165)</td>
</tr>
<tr>
<td>NULL</td>
<td>0;3</td>
<td>--</td>
<td>--</td>
<td>--</td>
</tr>
<tr>
<td>A</td>
<td>97</td>
<td>65</td>
<td>1</td>
<td>0;30</td>
</tr>
<tr>
<td>B</td>
<td>98</td>
<td>66</td>
<td>2</td>
<td>0;48</td>
</tr>
<tr>
<td>C</td>
<td>99</td>
<td>66</td>
<td>3</td>
<td>0;46</td>
</tr>
<tr>
<td>D</td>
<td>100</td>
<td>68</td>
<td>4</td>
<td>0;32</td>
</tr>
<tr>
<td>E</td>
<td>101</td>
<td>69</td>
<td>5</td>
<td>0;18</td>
</tr>
<tr>
<td>F</td>
<td>102</td>
<td>70</td>
<td>6</td>
<td>0;33</td>
</tr>
<tr>
<td>G</td>
<td>103</td>
<td>71</td>
<td>7</td>
<td>0;34</td>
</tr>
<tr>
<td>H</td>
<td>104</td>
<td>72</td>
<td>8</td>
<td>0;35</td>
</tr>
<tr>
<td>I</td>
<td>105</td>
<td>73</td>
<td>9</td>
<td>0;23</td>
</tr>
<tr>
<td>J</td>
<td>106</td>
<td>74</td>
<td>10</td>
<td>0;36</td>
</tr>
<tr>
<td>K</td>
<td>107</td>
<td>75</td>
<td>11</td>
<td>0;37</td>
</tr>
<tr>
<td>L</td>
<td>108</td>
<td>76</td>
<td>12</td>
<td>0;38</td>
</tr>
<tr>
<td>M</td>
<td>109</td>
<td>77</td>
<td>13</td>
<td>0;50</td>
</tr>
<tr>
<td>N</td>
<td>110</td>
<td>78</td>
<td>14</td>
<td>0;49</td>
</tr>
<tr>
<td>O</td>
<td>111</td>
<td>79</td>
<td>15</td>
<td>0;24</td>
</tr>
<tr>
<td>P</td>
<td>112</td>
<td>80</td>
<td>16</td>
<td>0;25</td>
</tr>
<tr>
<td>Q</td>
<td>113</td>
<td>81</td>
<td>17</td>
<td>0;16</td>
</tr>
<tr>
<td>R</td>
<td>114</td>
<td>82</td>
<td>18</td>
<td>0;19</td>
</tr>
<tr>
<td>S</td>
<td>115</td>
<td>83</td>
<td>19</td>
<td>0;31</td>
</tr>
<tr>
<td>T</td>
<td>116</td>
<td>84</td>
<td>20</td>
<td>0;20</td>
</tr>
<tr>
<td>U</td>
<td>117</td>
<td>85</td>
<td>21</td>
<td>0;22</td>
</tr>
<tr>
<td>V</td>
<td>118</td>
<td>86</td>
<td>22</td>
<td>0;47</td>
</tr>
<tr>
<td>W</td>
<td>119</td>
<td>87</td>
<td>23</td>
<td>0;17</td>
</tr>
<tr>
<td>X</td>
<td>120</td>
<td>88</td>
<td>24</td>
<td>0;45</td>
</tr>
<tr>
<td>Y</td>
<td>121</td>
<td>89</td>
<td>25</td>
<td>0;21</td>
</tr>
<tr>
<td>Z</td>
<td>122</td>
<td>90</td>
<td>26</td>
<td>0;44</td>
</tr>
<tr>
<td>1</td>
<td>49</td>
<td>33</td>
<td>--</td>
<td>0;120</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
<td>64</td>
<td>0</td>
<td>0;121</td>
</tr>
<tr>
<td>3</td>
<td>51</td>
<td>35</td>
<td>--</td>
<td>0;122</td>
</tr>
<tr>
<td>4</td>
<td>52</td>
<td>36</td>
<td>--</td>
<td>0;123</td>
</tr>
<tr>
<td>5</td>
<td>53</td>
<td>37</td>
<td>--</td>
<td>0;124</td>
</tr>
<tr>
<td>6</td>
<td>54</td>
<td>94</td>
<td>30</td>
<td>0;125</td>
</tr>
<tr>
<td>7</td>
<td>55</td>
<td>38</td>
<td>--</td>
<td>0;126</td>
</tr>
<tr>
<td>8</td>
<td>56</td>
<td>42</td>
<td>--</td>
<td>0;126</td>
</tr>
<tr>
<td>9</td>
<td>57</td>
<td>40</td>
<td>--</td>
<td>0;127</td>
</tr>
<tr>
<td>0</td>
<td>48</td>
<td>41</td>
<td>--</td>
<td>0;129</td>
</tr>
<tr>
<td>-</td>
<td>45</td>
<td>95</td>
<td>31</td>
<td>0;130</td>
</tr>
<tr>
<td>=</td>
<td>61</td>
<td>43</td>
<td>-–</td>
<td>0;131</td>
</tr>
<tr>
<td>[</td>
<td>91</td>
<td>123</td>
<td>27</td>
<td>0;26</td>
</tr>
<tr>
<td>]</td>
<td>93</td>
<td>125</td>
<td>29</td>
<td>0;27</td>
</tr>
<tr>
<td></td>
<td>92</td>
<td>124</td>
<td>28</td>
<td>0;43</td>
</tr>
<tr>
<td>;</td>
<td>59</td>
<td>58</td>
<td>--</td>
<td>0;39</td>
</tr>
<tr>
<td>'</td>
<td>39</td>
<td>34</td>
<td>--</td>
<td>0;40</td>
</tr>
<tr>
<td>,</td>
<td>44</td>
<td>60</td>
<td>--</td>
<td>0;51</td>
</tr>
<tr>
<td>.</td>
<td>46</td>
<td>62</td>
<td>--</td>
<td>0;52</td>
</tr>
<tr>
<td>/</td>
<td>47</td>
<td>63</td>
<td>--</td>
<td>0;53</td>
</tr>
<tr>
<td>`</td>
<td>96</td>
<td>126</td>
<td>--</td>
<td>(0;41)</td>
</tr>
<tr>
<td>ENTER (keypad)</td>
<td>13</td>
<td>--</td>
<td>10</td>
<td>(0;166)</td>
</tr>
<tr>
<td>/ (keypad)</td>
<td>47</td>
<td>47</td>
<td>(0;142)</td>
<td>(0;74)</td>
</tr>
<tr>
<td>* (keypad)</td>
<td>42</td>
<td>(0;144)</td>
<td>(0;78)</td>
<td>--</td>
</tr>
<tr>
<td>- (keypad)</td>
<td>45</td>
<td>45</td>
<td>(0;149)</td>
<td>(0;164)</td>
</tr>
<tr>
<td>+ (keypad)</td>
<td>43</td>
<td>43</td>
<td>(0;150)</td>
<td>(0;55)</td>
</tr>
<tr>
<td>5 (keypad)</td>
<td>(0;76)</td>
<td>53</td>
<td>(0;143)</td>
<td>--</td>
</tr>
</tbody>
</table>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/ANSI_escape_code">Wikipedia: ANSI escape code</a></li>
<li><a href="http://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html">Build your own Command Line with ANSI escape codes</a></li>
<li><a href="http://ascii-table.com/ansi-escape-sequences.php">ascii-table: ANSI Escape sequences</a></li>
<li><a href="https://bluesock.org/~willkg/dev/ansi.html">bluesock: ansi codes</a></li>
<li><a href="http://wiki.bash-hackers.org/scripting/terminalcodes">bash-hackers: Terminal Codes (ANSI/VT100) introduction</a></li>
<li><a href="https://invisible-island.net/xterm/ctlseqs/ctlseqs.html">XTerm Control Sequences</a></li>
<li><a href="https://vt100.net/">VT100 – Various terminal manuals</a></li>
<li><a href="https://xtermjs.org/docs/api/vtfeatures/">xterm.js – Supported Terminal Sequences</a></li>
</ul>
</div>
<div class="row">
<div class="col-xs-12">
</div>
</div>
<div style="height: 50px;"></div>
<div class="site-footer">
</div>
</div>
</div>
</article>
<script>
</script>
</body>
</html>
|