[net.micro.pc] Colors in DOS using PROMPT

pier@ur-univax.UUCP (05/24/85)

I was asked to repost an article on how to change the colors in DOS using
the DOS PROMPT command.
Let me say first that you need the ANSI.SYS device driver installed so that
the escape characters sequences can be interpreted.

The following is a command I use in a batch file to put the current directory,
and the date and time on the top line of the screen, and also set the
foregroung and background colors of that line and the rest of the screen.
This batch file has 4 parameters:

        the foreground color of the top line
        the background color of the top line
        the foreground color of the rest of the screen
        the background color of the rest of the screen


PROMPT $E[s                          ! save current cursor position
       $E[0;0H                       ! go to home position
       $E[3%1m$E[4%2m                ! set foreground (%1) and background (%2)
                                     ! colors of top line
       Directory: $P      $D    $T   ! print directory, date and time
       $E[K                          ! erase rest of line
       $E[3%3m$E[4%4m                ! foreground (%3) and background (%4)
                                     ! colors of rest of screen
       $E[K$E[u                      ! erase rest of line with new bacground 
                                     ! color and restore cursor position
       $N$G                          ! print the usual DOS prompt (drive and >)

This command is commented here. To use it, remove the comments and put 
everything on one single line, as the argument of the  DOS PROMPT command
ends at the end of the line.

Hope this helps.

Pierre Darmon
University of Rochester