I am using ANSI escape codes in my bash script to change the color of echo commands
#/bin/bash
cecho() {
local code="\033["
case "$1" in
black | bk) color="${code}0;30m";;
red | r) color="${code}1;31m";;
green | g) color="${code}1;32m";;
yellow | y) color="${code}1;33m";;
blue | b) color="${code}1;34m";;
purple | p) color="${code}1;35m";;
cyan | c) color="${code}1;36m";;
gray | gr) color="${code}0;37m";;
*) local text="$1"
esac
[ -z "$text" ] && local text="$color$2${code}0m"
echo -e "$text"
}
cecho b "This is blue"
cecho r "This is red"
The issue is i am using a Terminal color scheme and it causes the cecho command to display wrong colors , for eg. If i try to output cecho command for purple color , it gets displayed in yellow color. I think my internal Terminal color sceheme is conflicting with these ANSI color codes. Is it somehow possible to override any internal color schemes and force display the colors defined in bash script ? Wrong colors being displayed in echo might be due to other reasons as well , conflict with internal color scheme is just my guess .

my internal Terminal color sceheme is conflicting with these ANSI color codesThe color scheme is literally there to interpret asci escape codes. It's the same thing, not a conflict. The 16colors terminla color scheme is the interpretation of escape sequences to colors. If you setup your terminal to interpret1;35mas yellow, well, then it's going to be yellow.