Difference between revisions of "ASCII Escapes For Bash"

From Nearline Storage
Jump to navigation Jump to search
m
m
Line 3: Line 3:
 
Bash Color Escape Codes
 
Bash Color Escape Codes
  
Echo (echo -e) the following escape codes inside \e[ESCCODEm to colorize text in Bash:
+
Echo (echo -e) the following escape codes inside <code>\e['''''nn;nn'''''m</code> to colorize text in Bash:
  
 
{| class="wikitable" style="margin-left: 40px;"
 
{| class="wikitable" style="margin-left: 40px;"
Line 54: Line 54:
 
|00;37
 
|00;37
 
|-
 
|-
| style="font-weight: bold;" | White
+
| style="color: #e9e0d9; font-weight: bold;" | White
 
|01;37
 
|01;37
 
|}
 
|}
Line 64: Line 64:
 
====Remove Color====
 
====Remove Color====
  
Echo \e[00m to remove text color modifications:
+
Echo <code>\e[00m</code> to remove text color modifications:
  
  bash$ echo -n '\e[00m'
+
  bash$ echo -ne '\e[00m'

Revision as of 18:29, 31 August 2013

Stolen from http://hacktux.com/bash/colors

Bash Color Escape Codes

Echo (echo -e) the following escape codes inside \e[nn;nnm to colorize text in Bash:

Color Escape
Black 00;30
Dark Gray 01;30
Red 00;31
Light Red 01;31
Green 00;32
Light Green 01;32
Brown 00;33
Yellow 01;33
Blue 00;34
Light Blue 01;34
Purple 00;35
Light Purple 01;35
Cyan 00;36
Light Cyan 01;36
Light Gray 00;37
White 01;37

Make sure to use echo -e to enable interpretation of backslash escapes:

bash$ echo -e "This is red->\e[00;31mRED\e[00m"

Remove Color

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

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