I am writing a user command as an alias that use awk printing output in different colors.
The little snippet I came up with works fine in KDE Konsole but not in xterm or gnome-terminal.
My shell is a BASH on SLES11 and the terminal is set to XTERM
myuser@myhost:~> env |grep -i term
TERM=xterm
COLORTERM=1
The alias is defined as follows:
alias myCustomPS="\
awk '{ \
gsub(/\.CONTEXT/,\"\", \$11); \
split(\$11,v,\"_D\"); \
split(\$13,h,\".\"); \
if (\$1==\"usr1\")
printf \"pid [\033[1;37;48;2;0;0;128m %5s \033[0m] [\033[1;37;48;2;0;0;128m %.8s \033[0m] \033[1;37;48;2;0;0;128m %-8.10s \033[0m D%-8s\n\", \$2, \$1, h[1], v[2]; \
else if (\$1==\"usr2\") \
printf \"pid [\033[1;37;48;2;0;170;170m %5s \033[0m] [\033[1;37;48;2;0;170;170m %.8s \033[0m] \033[1;37;48;2;0;170;170m %-8.10s \033[0m D%-8s\n\", \$2, \$1, h[1], v[2]; }'"
the output I get is displaying correctly ONLY in Konsole.
Both xterm and gnome-terminal instead don't show it correctly. In Xterm no color at all is shown, in gnome-terminal only the font color is shown, no background.
any idea, or alternative ways to universally colorize the awk output? Thanks, Roberto