Skip to content

Instantly share code, notes, and snippets.

@JBlond
Forked from iamnewton/bash-colors.md
Last active November 10, 2026 18:37
Show Gist options
  • Select an option

  • Save JBlond/2fea43a3049b38287e5e9cefc87b2124 to your computer and use it in GitHub Desktop.

Select an option

Save JBlond/2fea43a3049b38287e5e9cefc87b2124 to your computer and use it in GitHub Desktop.
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
\e[0;36m Cyan
\e[0;37m White

Bold

Value Color
\e[1;30m Black
\e[1;31m Red
\e[1;32m Green
\e[1;33m Yellow
\e[1;34m Blue
\e[1;35m Purple
\e[1;36m Cyan
\e[1;37m White

Underline

Value Color
\e[4;30m Black
\e[4;31m Red
\e[4;32m Green
\e[4;33m Yellow
\e[4;34m Blue
\e[4;35m Purple
\e[4;36m Cyan
\e[4;37m White

Background

Value Color
\e[40m Black
\e[41m Red
\e[42m Green
\e[43m Yellow
\e[44m Blue
\e[45m Purple
\e[46m Cyan
\e[47m White

High Intensity

Value Color
\e[0;90m Black
\e[0;91m Red
\e[0;92m Green
\e[0;93m Yellow
\e[0;94m Blue
\e[0;95m Purple
\e[0;96m Cyan
\e[0;97m White

Bold High Intensity

Value Color
\e[1;90m Black
\e[1;91m Red
\e[1;92m Green
\e[1;93m Yellow
\e[1;94m Blue
\e[1;95m Purple
\e[1;96m Cyan
\e[1;97m White

High Intensity backgrounds

Value Color
\e[0;100m Black
\e[0;101m Red
\e[0;102m Green
\e[0;103m Yellow
\e[0;104m Blue
\e[0;105m Purple
\e[0;106m Cyan
\e[0;107m White

Reset

Value Color
\e[0m Reset

other styles

echo -e "\e[1mbold\e[0m"
echo -e "\e[3mitalic\e[0m"
echo -e "\e[3m\e[1mbold italic\e[0m"
echo -e "\e[4munderline\e[0m"
echo -e "\e[9mstrikethrough\e[0m"
echo -e "\e[31mHello World\e[0m"
echo -e "\x1B[31mHello World\e[0m"

overline

printf '\033[53mHello\033[0m\n'
#!/bin/sh
printf "\e[0;30mBlack \e[1;30mbold Black \e[0;90mhigh intensity Black\n"
printf "\e[0;31mRed \e[1;31mbold Red \e[0;91mhigh intensity Red\n"
printf "\e[0;32mGreen \e[1;32mbold Green \e[0;92mhigh intensity Green\n"
printf "\e[0;33mYellow \e[1;33mbold Yellow \e[0;93mhigh intensity Yellow\n"
printf "\e[0;34mBlue \e[1;34mbold Blue \e[0;94mhigh intensity Blue\n"
printf "\e[0;35mPurple \e[1;35mbold Purple \e[0;95mhigh intensity Purple\n"
printf "\e[0;36mCyan \e[1;36mbold Cyan \e[0;96mhigh intensity Cyan\n"
printf "\e[0;37mWhite \e[1;37mbold White \e[0;97mhigh intensity White\n"
printf '\033[53mHello Overline\033[0m\n'
@JBlond

JBlond commented May 1, 2025 •

Copy link
Copy Markdown
Author

@tbrowder

No that is not supported. You can use only unicode for that.

@tbrowder

tbrowder commented May 1, 2025

Copy link
Copy Markdown

Thanks so much.

@BassXVII

Copy link
Copy Markdown

Thank you everyone for your help here. I have spent the last 4 hours learning from these links here.
:)

@OctaYus

OctaYus commented Aug 5, 2025

Copy link
Copy Markdown

love it, thank you.

@travisjupp

Copy link
Copy Markdown

Good Resource!
ANSI styles I use fairly often (mainly for tests) and just updated: styles.js
View the styles in the "Run tests" section of this github action

@eliotttak

Copy link
Copy Markdown

Very good and useful! Just wanting to notice that in some language \e make an error. In this case you have to use \033.

image

@TracktorRaptor

TracktorRaptor commented Jan 7, 2026 •

Copy link
Copy Markdown

For anyone who has the \e problem in C#, make sure to update and use the latest .NET version - .NET 9 for C#-13 which supports these kinds of characters.

@ferrum-the-beautiful

Copy link
Copy Markdown

@w495

w495 commented Mar 10, 2026

Copy link
Copy Markdown

For anyone who has the \e problem in C#, make sure to update and use the latest .NET version - .NET 9 for C#-13 which supports these kinds of characters.

Use \0033 — as octet portable char (as \0XYZ) or \033 as common char for shell or \x1b as hexadecimal analog.

@eabase

eabase commented May 9, 2026

Copy link
Copy Markdown

In Bash: ANSI ESCAPE = \e = \033 = \x1b.

@cipitaua

Copy link
Copy Markdown
#!/bin/bash

echo

i=0

n=$(tput colors)

clear

while [ "$i" -lt "$n" ]; do

    line=$(( i / 8 ))
    col=$(( ( i % 8 ) * 24 ))
    tput cup $line $col
    tput setab "$i"
    echo -n "              "
    tput setab 0
    [ $i -eq 0 ] &&  tput setab 7
    [ $i -ge 232 -a $i -le 239 ] &&  tput setab 7
    tput setaf "$i"
    echo -n $(tput setaf "$i" | sed 's/'`echo -e "\033\["`'/ /g')
    tput setab 0
    i=$((i + 1))

    awk -vi=$i 'BEGIN{if(i%8==0) print " " }'

done

echo
echo
image

@wertvolker

Copy link
Copy Markdown

Is there a recognized code for 'overline' ("opposite" of underline)?

according to https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
the requested code is 53 , e.g. "\033[53m"

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