>I use an (IBM/COLOR) compatible terminal that allows color and such. I
>have a text file in my home directory that had a sample of all the ANSI
>escape codes. When I "cat" the file it turns out great, color, italics
>and stuff. Is there a way to get these escape code into a prompt, or into
>a shell script. I have a menu script that makes my UNIX account look like
>a local BBS, it's neet, but no color :(
>I am using echo to print lines right now and would like to get color in it.
>Anyway, and help (or point me to the right FAQ) would be appreciated, I
>would post my menu script so others can see it, play with it.. :)
>I am on a BSD 4.3, and I use TCSH. I could change shells if necesary, but
>I like the editing TCSH offers.
I had the same problem when I started using tcsh. The one thing I miss about
csh is the ability to use ansi codes in one's prompt. However, there are
tcsh prompt codes for bold, underline, and standout. You can make your own
termcap file to redefine those to the colors you want and then use them. For
instance, here is the code I use to set my prompt (I don't like the way it
looks on xterms, so I use a different set of codes):
if ($?TERM && ("$TERM" == "xterm")) then
set prompt="%B%m:%b%~ [\!] "
if ("$HOSTTYPE" == "decstation") then
stty erase
else
if ("$HOSTTYPE" == "hp9000s700") then
stty erase
else
endif
endif
else
set prompt="%B%m:%b%S%~%s %U[\!]%u "
endif
I have two termcap files (I'll explain below):
(The first file contain one very long line. I don't know how it will come
out when posted, so I apologize if you can't see it all. If you have trouble
with it, I can email it or try again, inserting returns.)
myterm1:
:cr=^M:do=^J:nl=^J:bl=^G:co#80:li#24:cl=50\E[;H\E[2J:le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:ce=3\E[K:cd=50\E[J:so=2\E[31m:se=2\E[m:us=2\E[35m:ue=2\E[m:md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:rf=/usr/lib/tabset/vt100:rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:ta=^I:pt:sr=5\EM:vt#3:xn:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:
myterm2:
d0|vt100|vt100-am|vt100am|dec vt100:\
:cr=^M:do=^J:nl=^J:bl=^G:co#80:li#24:cl=50\E[;H\E[2J:\
:le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\
:ce=3\E[K:cd=50\E[J:so=2\E[31m:se=2\E[m:us=2\E[35m:ue=2\E[m:\
:md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\
:rf=/usr/lib/tabset/vt100:\
:rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\
:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\
:ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:ta=^I:pt:sr=5\EM:vt#3:xn:\
:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:
The important codes are "us" (underline), "so" (standout), and, I think,
"md" (bold). I'm not quite sure, so check "man termcap."
Anyway, I'm not sure why I need to have two termcap files, but I had a lot
of problems getting all this to work. This method solved the problems,
though. The following is from my .login:
.login:
stty tostop newcrt intr ^c
set noglob
umask 077
setenv TERMCAP `cat /home/channing/reentry/ggurman/text/myterm1`
eval `/usr/ucb/tset -s - -k^U -e^H -m su:\?$TERM \?$TERM`
cd $HOME
[...]
if ("$TERM" == "vt100") then
setenv TERMCAP ~/text/myterm2
run chmail
biff y
[...]
endif
Good luck.
Gail
--
---------------------------------------------------------------------------
JOB FISHING: I'm looking for an entry-level programming, quality assurance,
or tech writing position in the East Bay. My resume is available on request.