Hamilton LaboratoriesHamilton C shell 2012User guideLanguage reference

ANSI escape sequences

Oregon Coast

ANSI escape sequences
Previous | Next

Topics

Syntax
Usage
See also

Syntax

In this table, Esc refers to the 0x1B escape character.

Escape sequence Meaning
Esc [ row; col H

Set cursor position, counting from (1, 1) in the upper left-hand corner.

Esc [ row; col f

Set cursor position, counting from (1, 1) in the upper left-hand corner.

Esc [ n A

Cursor up n rows.

Esc [ n B

Cursor down n rows.

Esc [ n C

Cursor forward n rows.

Esc [ n D

Cursor backward n rows.

Esc [ s

Save cursor position.

Esc [ u

Restore cursor position.

Esc [ 2 J

Erase display and move cursor to upper left-hand corner.

Esc [ K

Erase to end of line.

Esc [ g m

Set graphics rendition (color, etc.). More than one change can be specified by using semicolons between each g value:

Basic attributes
0 Normal
1 Bright
2 Dim
5 Bright background
7 Reverse video
8 Hidden
Foreground colors
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
Background colors
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White

Usage

The C shell and all the utilities that come with it generate these ANSI escape sequences when writing to a file or pipe. When writing to the console, they interpret these sequences.

The builtin ansi() procedure can be used to generate the SGR color sequences without having to know the actual encoding, e.g., ansi("red").

See also

Escaping a single character
COLORS environment variable
ansi() procedure
Builtin procedures
Procedures
Quoting
Tutorial: Customizing the screen colors
Tutorial: Procedures

Previous | Next

Getting started with Hamilton C shell

Hamilton C shell, as it first wakes up.

Getting started with Hamilton C shell

A first few commands.

You can set the screen colors to your taste.

You can set the screen colors to your taste.