Skip to content

Instantly share code, notes, and snippets.

@kana-ph
Created March 15, 2017 13:58
Show Gist options
  • Save kana-ph/f670798a6f4dfe5659adccf71b12f10a to your computer and use it in GitHub Desktop.
Save kana-ph/f670798a6f4dfe5659adccf71b12f10a to your computer and use it in GitHub Desktop.
Format text and add color to bash echo

Echo

echo -e "\033[X;YYmFORMATTED TEXT HERE!\033[0;0m"

Where:

  • X is the Format,
  • YY is the colour code, and
  • \033[0;0m clears the formatting

Formats

0 Normal Style
1 Bold
2 Dim
4 underline
5 blinking
7 reverse
8 Invisible

Source http://stackoverflow.com/a/42449998

Colours

Black        0;30     Dark Gray     1;30
Red          0;31     Light Red     1;31
Green        0;32     Light Green   1;32
Brown/Orange 0;33     Yellow        1;33
Blue         0;34     Light Blue    1;34
Purple       0;35     Light Purple  1;35
Cyan         0;36     Light Cyan    1;36
Light Gray   0;37     White         1;37

Source http://stackoverflow.com/a/5947802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment