Skip to content

Add ANSI escape codes tutorial#5485

Open
yuxi-liu-wired wants to merge 2 commits intoadambard:masterfrom
yuxi-liu-wired:ansi-tutorial
Open

Add ANSI escape codes tutorial#5485
yuxi-liu-wired wants to merge 2 commits intoadambard:masterfrom
yuxi-liu-wired:ansi-tutorial

Conversation

@yuxi-liu-wired
Copy link
Copy Markdown
Contributor

Adds a tutorial for ANSI escape codes, the character sequences that control terminal text formatting, color, and cursor movement.

The tutorial covers:

  • ESC character representations (\e, \033, \x1b) and CSI/SGR fundamentals
  • Text formatting attributes: bold, dim, italic, underline, blink, inverse, hidden, strikethrough
  • Standard 8 colors (foreground 30-37, background 40-47)
  • Bright/high-intensity colors (90-97, 100-107)
  • 256-color mode (38;5;N / 48;5;N) with the 6x6x6 color cube and grayscale ramp
  • 24-bit true color (38;2;R;G;B / 48;2;R;G;B) with a gradient demo
  • Cursor movement (up/down/forward/back, absolute positioning)
  • Screen and line clearing (erase in display / erase in line)
  • Best practices: reset after use, variables for readability, terminal detection, NO_COLOR, tput

Every example in the code block produces visible output when run with bash LearnANSI.sh.

Yuxi Liu and others added 2 commits March 17, 2026 17:26
Covers text formatting, 8/16/256/true color, cursor movement,
screen clearing, terminal title, alternate screen buffer, and
best practices for using colors in scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The indented code block style conflicts with fenced blocks used
elsewhere in the repo, triggering MD046. Use 6-backtick fence to
contain inner 3- and 5-backtick examples. Content unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant