ANSI Graphics & TCSH/BSD

ANSI Graphics & TCSH/BSD

Post by Nick Ells » Mon, 29 Aug 1994 09:52:05



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.

--

 
 
 

ANSI Graphics & TCSH/BSD

Post by Gail Gurm » Mon, 29 Aug 1994 12:00:57



>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.

 
 
 

ANSI Graphics & TCSH/BSD

Post by Matija Nal » Tue, 30 Aug 1994 03:24:49


: 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

:     set prompt="%B%m:%b%~ [\!] "

I missed it too, until I read the man page and done something like :

set prompt = "%{^[[36m%}%m%{^[[0m%}:%~\>"

note : ^[ is ESC character - if inputing from command line, press CTRL-V and
then ESC to get it.

This would print host name in cyan, followed by cwd and '>' in normal
color...

that was tcsh 6.04.00 (Cornell) 93/07/03 (i386-linux) options 8b,dl,al

hope it helps...
                                                Matija

 
 
 

ANSI Graphics & TCSH/BSD

Post by Gail Gurm » Tue, 30 Aug 1994 04:31:14



>I missed it too, until I read the man page and done something like :
>set prompt = "%{^[[36m%}%m%{^[[0m%}:%~\>"
>note : ^[ is ESC character - if inputing from command line, press CTRL-V and
>then ESC to get it.

Hmm. I did see that in the man page and I thought I tried it and it didn't
work, but perhaps I did it wrong. I'll certainly try it again.

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.

 
 
 

ANSI Graphics & TCSH/BSD

Post by Gail Gurm » Tue, 30 Aug 1994 05:09:31




>>I missed it too, until I read the man page and done something like :
>>set prompt = "%{^[[36m%}%m%{^[[0m%}:%~\>"
>>note : ^[ is ESC character - if inputing from command line, press CTRL-V and
>>then ESC to get it.
>Hmm. I did see that in the man page and I thought I tried it and it didn't
>work, but perhaps I did it wrong. I'll certainly try it again.

Well, I worked on it and was able to recreate my prompt as follows:

before:
set prompt="%B%m:%b%S%~%s %U[\!]%u "

after:
set prompt = "%{^[[34;1m%}%m:%{^[[0m%}%{^[[31m%}%~ %{^[[35m%}[\!]%{^[[34m%} "

The advantage of the first is that it's easier to read. The advantage of the
second is that it's easy to change (if you know the proper ansi codes). Also,
the second doesn't require any fancy termcap stuff. As for the messiness, it
can be cleaned up by setting some variables,

e.g.,
set BRBLU = %{^[[34;1m%}

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.

 
 
 

ANSI Graphics & TCSH/BSD

Post by Nick Ells » Tue, 30 Aug 1994 14:25:15


: : 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

: :     set prompt="%B%m:%b%~ [\!] "

: I missed it too, until I read the man page and done something like :

: set prompt = "%{^[[36m%}%m%{^[[0m%}:%~\>"

: note : ^[ is ESC character - if inputing from command line, press CTRL-V and
: then ESC to get it.

: This would print host name in cyan, followed by cwd and '>' in normal
: color...

: that was tcsh 6.04.00 (Cornell) 93/07/03 (i386-linux) options 8b,dl,al

: hope it helps...
:                                               Matija

This Works great!!!! Thank You!!!! I am a happy COLOR user now! ;)

                ___                  ||||                  ___
           ____(   \              .-'    `-.              /   )____
          (____     \_____       /  (O  O)  \       _____/     ____)
         (____            `-----(      )     )-----'            ____)
          (____     _____________\  .____.  /_____________     ____)
            (______/              `-.____.-'              \______)

            *Hug*     *Hug*    *Hug*     *Hug*          *Hug*
            *Hug*     *Hug*    *Hug*     *Hug*       *Hug* *Hug*
            *Hug*     *Hug*    *Hug*     *Hug*      *Hug*   *Hug*
            *Hug*     *Hug*    *Hug*     *Hug*     *Hug*
            *Hug**Hug**Hug*    *Hug*     *Hug*    *Hug*
            *Hug**Hug**Hug*    *Hug*     *Hug*    *Hug*    *Hug**Hug*
            *Hug*     *Hug*    *Hug*     *Hug*     *Hug*     *Hug*
            *Hug*     *Hug*     *Hug*   *Hug*       *Hug*   *Hug*
            *Hug*     *Hug*      *Hug* *Hug*         *Hug* *Hug*
            *Hug*     *Hug*         *Hug*               *Hug*

--

 
 
 

1. tcsh with ansi graphics

Is there a version of tcsh that has support for ansi graphics?
I would like to use tcsh instead of csh but it would be nice
to have ansi color prompts (although not absolutely necessary).
Thanks in advance.

--
          Raymond W.M. Kan             |



2. ipmasqadm not working

3. csh/tcsh & ANSI colors

4. "what passes for Unix" quote

5. SEYON & ANSI-BBS graphics

6. synchronize to the physical disk

7. tcsh prompt with ANSI colors

8. Why have tried the Gnome 2.0 Beta3

9. Using ANSI color escape sequences in tcsh

10. String Functions & ANSI->K & R

11. C code and K&R and ANSI and BSD and reverse compatibility

12. ANSI function prototypes for BSD system calls

13. Ansi chracter graphic.