Catalog / ANSI Escape Codes Cheatsheet
ANSI Escape Codes Cheatsheet
A quick reference guide to ANSI escape codes, essential for adding color and formatting to terminal output. This cheat sheet covers text styles, colors, cursor movement, and useful bash utilities, making it easy to customize your command-line interface.
Text Formatting
Basic Formatting Codes
|
Clear all formatting (reset to default). |
|
Bold or increased intensity. |
|
Underline. |
|
Blink (may not work in all terminals). |
|
Invert (swap foreground and background colors). |
|
Hidden (useful for passwords). |
Foreground Colors (30-37)
|
Black foreground. |
|
Red foreground. |
|
Green foreground. |
|
Yellow foreground. |
|
Blue foreground. |
|
Magenta foreground. |
|
Cyan foreground. |
|
White foreground. |
Background Colors & Extended Colors
Background Colors (40-47)
|
Black background. |
|
Red background. |
|
Green background. |
|
Yellow background. |
|
Blue background. |
|
Magenta background. |
|
Cyan background. |
|
White background. |
Extended Color Codes (256 Colors)
Use the following format to access 256 colors: Where |
Example: |
Cursor Movement & Screen Control
Cursor Movement Codes
|
Move the cursor up L lines. |
|
Move the cursor down L lines. |
|
Move the cursor forward C columns. |
|
Move the cursor backward C columns. |
|
Move the cursor to row R, column C. |
|
Save the current cursor position. |
|
Restore the last saved cursor position. |
Screen Control Codes
|
Clear the entire screen. |
|
Clear the line from the cursor to the end of the line. |
|
Clear the line from the cursor to the beginning of the line. |
|
Clear the entire line. |
|
Move cursor to top left corner (0,0). |
Bash Utilities & Examples
Bash Functions
|
Usage: Call |
Examples
|
|