How to category Design category Development category News category

Colours in the Mac terminal…

Hope someone finds this useful too… Found plenty of articles on enabling colours in terminal, however very few which show you how to use colours.

Based on – http://stackoverflow.com/questions/18560647/how-to-make-bash-shell-display-colorful-text.

To get this working on the mac the the codes are slightly different from those in the stackoverflow article…

RCol='\033[0m'    # Text Reset

# Regular           Bold                Underline           High Intensity      BoldHigh Intens     Background          High Intensity Backgrounds
Bla='\033[30m';     BBla='\033[1;30m';    UBla='\033[4;30m';    IBla='\033[90m';    BIBla='\033[1;90m';   On_Bla='\033[40m';    On_IBla='\033[100m';
Red='\033[31m';     BRed='\033[1;31m';    URed='\033[4;31m';    IRed='\033[91m';    BIRed='\033[1;91m';   On_Red='\033[41m';    On_IRed='\033[101m';
Gre='\033[32m';     BGre='\033[1;32m';    UGre='\033[4;32m';    IGre='\033[92m';    BIGre='\033[1;92m';   On_Gre='\033[42m';    On_IGre='\033[102m';
Yel='\033[33m';     BYel='\033[1;33m';    UYel='\033[4;33m';    IYel='\033[93m';    BIYel='\033[1;93m';   On_Yel='\033[43m';    On_IYel='\033[103m';
Blu='\033[34m';     BBlu='\033[1;34m';    UBlu='\033[4;34m';    IBlu='\033[94m';    BIBlu='\033[1;94m';   On_Blu='\033[44m';    On_IBlu='\033[104m';
Pur='\033[35m';     BPur='\033[1;35m';    UPur='\033[4;35m';    IPur='\033[95m';    BIPur='\033[1;95m';   On_Pur='\033[45m';    On_IPur='\033[105m';
Cya='\033[36m';     BCya='\033[1;36m';    UCya='\033[4;36m';    ICya='\033[96m';    BICya='\033[1;96m';   On_Cya='\033[46m';    On_ICya='\033[106m';
Whi='\033[37m';     BWhi='\033[1;37m';    UWhi='\033[4;37m';    IWhi='\033[97m';    BIWhi='\033[1;97m';   On_Whi='\033[47m';    On_IWhi='\033[107m';

#example
echo -e "${Gre}Green and ${BYel}Bold yellow${RCol}"
Tags:

admin

qr code

Comments are closed.