Show Menu
Cheatography

Bash Script Colors Cheat Sheet by

Different ways to change the color of text in bash scripts

TPUT Control Codes

setf
Foreground color (text)
setaf
Foreground color (ANSI escaped)
setb
Background color
setab
Background color (ANSI escaped)
bold
Brighten all colors
dim
Darken all colors
rev
Reverse color pallete
smul
Begin underl­ining
rmul
Stop underl­ining
smso
Enter Standout Mode
rmso
Exit Standout Mode
smcup
Clear
clear
Clear
reset
Reset Screen Size
rmcup
Restore
sgr0
Revert all attribute changes
Usage: tput <co­ntr­ol> [color]
Red Hello:
tput setaf 1;echo "­Hel­lo";tput sgr0

Light Green ps:
tput setaf 2;tput bold;p­s;tput sgr0

TPUT Color Codes

Black
0
Red
1
Green
2
Yellow
3
Blue
4
Magenta
5
Cyan
6
Light Grey
7
 

LS_COLORS File Codes

Block Device (buffered)
bd
File with Capability
ca
Character Device (unbuf­fered)
cd
Directory
di
Door
do
End Code
ec
Executable File
ex
File
fi
Left Code
lc
Symbolic Link
ln
Multi Hard Link
(File with more than one link)
mh
Missing File
(Pointed to by a symlink)
mi
Orphaned Symbolic Link
(Points to a missing file)
or
Other-­Wri­table Directory
ow
Named Pipe
pi
Right Code
rc
Socket File
so
Directory Sticky (+t)
st
File setuid (u+s)
su
Sticky AND Other-­Wri­table
tw
File Extension Specific
*.example
 
.example
Create a dircolors file with
dircolors -p > ~/.dir­colors

see dir_co­lor­s(1), dir_co­lors(5) for more info
 

ANSI Control Codes

Reset
0
Bold
1
Dim
2
Underline on
4
Underline off
24
Blink start
5
Blink end
25
Inverse pallete start
7
Inverse pallete end
27
Conceal
8
Normal
22
see consol­e_c­odes(4) for more inform­ation

ANSI Color Codes

Color
Text
Background
Black
30
40
Red
31
41
Green
32
42
Yellow
33
43
Blue
34
44
Magenta
35
45
Cyan
36
46
Light Grey
37
47
                               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          Linux Every Day Commands Cheat Sheet