Home > Linux > Bash Colors

Bash Colors

Bash Color Escape Codes

You can echo (echo -e) the following escape codes inside \e[ESCAPECODEm to colorize the text in your bash console:

  • Black 0;30
  • Dark Gray 1;30
  • Red 0;31
  • Light Red 1;31
  • Green 0;32
  • Light Green 1;32
  • Brown 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

Make sure you use „echo -e“ to enable the interpretation of the backslash escapes:

bash$ echo -e "This is bright green -> \e[01;32mGREENCOLOREDTEXT\e[00m"

Remove the Color

Echo \e[00m to remove the  color modifications from the text:

bash$ echo -n '\e[00m'

Look how the colors appear on your system:

Copy the code into an new created shell script for example colors.sh and make it executable (chmod +x colors.sh).

echo -e "This is \e[00;30mBlack\e[00m 0;30"
echo -e "This is \e[01;30mDark Gray\e[00m 1;30"
echo -e "This is \e[00;31mRed\e[00m 0;31"
echo -e "This is \e[01;31mLight\e[00m Red 1;31"
echo -e "This is \e[00;32mGreen\e[00m 0;32"
echo -e "This is \e[01;32mLight Green\e[00m 1;32"
echo -e "This is \e[00;33mBrown\e[00m 0;33"
echo -e "This is \e[01;33mYellow\e[00m 1;33"
echo -e "This is \e[00;34mBlue\e[00m 0;34"
echo -e "This is \e[01;34mLight Blue\e[00m 1;34"
echo -e "This is \e[00;36mCyan\e[00m 0;36"
echo -e "This is \e[01;36mLight Cyan\e[00m 1;36"
echo -e "This is \e[00;35mPurple\e[00m 0;35"
echo -e "This is \e[01;35mLight\e[00m Purple 1;35"
echo -e "This is \e[00;37mLight\e[00m Gray 0;37"
echo -e "This is \e[01;37mWhite\e[00m 1;37"

Execute the script (./colors.sh) and it should be look similar to this:

Further informations: ANSI escape code – Colors

KategorienLinux Tags: ,
  1. Bisher keine Kommentare
  1. Bisher keine Trackbacks
Du musst Dich anmelden um einen Kommentar zu schreiben