ANSI escape
also: escape sequence, CSI sequence, ECMA-48
A sequence of special characters that control text formatting, colors, and cursor movement in terminal output. ANSI escapes allow programs to style terminal text without changing the underlying data.
ANSI escape sequences are control codes that begin with the escape character (ASCII 27, or \x1b) followed by bracket and parameters. They instruct compatible terminals to interpret commands like changing text color, moving the cursor, or clearing the screen, rather than printing the characters literally.
A common example is coloring text red: \x1b[31mHello\x1b[0m displays "Hello" in red, then resets to default color. The sequence [31m means "set foreground to red" and [0m means "reset all attributes."
ANSI escapes are widely used by terminal utilities like grep, ls, and shell prompts to add visual appeal. You can test them with: echo -e "\033[32mGreen text\033[0m" (where \033 is octal for the escape character).