Links
Tag cloud
Picture wall
Daily
RSS Feed
  • RSS Feed
  • Daily Feed
  • Weekly Feed
  • Monthly Feed
Filters

Links per page

  • 20 links
  • 50 links
  • 100 links

Filters

Untagged links
bash:tip_colors_and_formatting - FLOZz' MISC https://misc.flogisoft.com/bash/tip_colors_and_formatting
Fri Apr 10 16:41:54 2020 archive.org

Bash tips: Colors and formatting (ANSI/VT100 Control sequences)

The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ; they can display colors and formatted texts thanks to escape sequences.

Those sequences are composed of the Escape character (often represented by “^[” or “<Esc>”) followed by some other characters: “<Esc>[FormatCodem”.

In Bash, the <Esc> character can be obtained with the following syntaxes:

\e
\033
\x1B

Examples:
Code (Bash) Preview

    echo -e "\e[31mHello World\e[0m"

Hello World

    echo -e "\033[31mHello\e[0m World"

Hello World

NOTE¹: The -e option of the echo command enable the parsing of the escape sequences.

NOTE²: The “\e[0m” sequence removes all attributes (formatting and colors). It can be a good idea to add it at the end of each colored text. ;)

NOTE³: The examples in this page are in Bash but the ANSI/VT100 escape sequences can be used in every programming languages.

bash tips formatage color
1578 links, including 7 private
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Theme by kalvn