Due to my inability to leave anything alone, I've modified the CD command
procedure once again.  The first modification fixes an intermittent problem
when the ~ (home directory) symbol is used as a part of the path name.  The
other modification is an enhancement:  You can now have the procedure set
your prompt for you.

I've tried to make it so that every user can customize their prompt to
anything they like.  To facilitate this, there are two symbols you have to
create:  prompt_format and prompt_params.  You don't have to remember these
names as the procedure sets them up for you.  Here is the new syntax for
setting up CD (put this line in your LOGIN.COM):

    $ SETUP CD [<prompt-format> <prompt-params>]

If you specify either parameter, you must specify both.  There are no
default values for these parameters.   If you leave out the optional
parameters, CD will work the way it always has.  The formats of the new
parameters are described below.

prompt-format

    A string surrounded with double quotes.  Anything can appear in between
    the quotes.  There is a special sequence "!AS" (case sensitive!!!) that
    you include in the prompt format that the CD procedure replaces with the
    parameter(s) you specify in <prompt-params>.

prompt-params

    A quoted comma seperated list of symbols that the CD procedure will use
    to fill in <prompt-format> to create the final prompt.  There are
    several symbols defined for you by the CD procedure:

        CD$HOST    - The name of the host you are logged into.
        CD$CUR     - The full file specification of the directory you are
                     currently in.  Example:  USER_DISK:[USER]
        CD$DIR     - Just the file specification of the directory you are
    		     currently in.  Example:  [USER]
        CD$DIR_RAW - CD$DIR minus the "[]".  Example:  USER
        CD$DEVICE  - Only the disk name portion of the full file spec for
                     the directory you are currently in.  Example:  USER_DISK
        CD$CSI     - Command Sequence Introducer.  The special ASCII character
    		     used by VT2xx, VT3xx, and VT4xx to denote the beginning
                     of a control sequence.  ASCII value 155.
        CD$ESC     - ASCII Escape character.  ASCII value 27.

The easiest way to demonstrate how to use these parameters is with some
examples.

Example 1

    $ SETUP CD "!AS> " "CD$HOST"

The preceeding tells CD to set your prompt to the name of the node you are
logged into followed by "> ".  If you log into VAX2, the resulting prompt
will be:

    VAX2>

Example 2

    $ SETUP CD "!AS.!AS> " "CD$DEVICE,CD$DIR_RAW"

This tells CD to set your prompt to your current default device followed by
a period, the raw directory name and then the string "> ".  If you login
directory is STUDENT_DISK:[USER], your prompt would be:

    STUDENT_DISK.USER>

Example 3

    $ SETUP CD "!AS1m!AS> !ASm" "CD$CSI,CD$CUR,CD$CSI"

This is a little fancy.  This tells CD to make the prompt your current
default directory but use BOLD characters.  The VT2xx+ command sequence for
bold characters is CSI followed by "1m".  And the sequence to return to
plain characters is CSI followed by "m".  Control sequences are case
sensitive.  The above will result in a prompt that looks like this except,
of course, it will appear in bold type:

    STUDENT_DISK:[USER]>

There a lot of other things you can do, but that is left as an exercise to
the reader.

There are several things you need to be aware of.  If you're doing VT100
emulation you'll have to use CD$ESC and use "[1m" in the format to start
the bold sequence and CD$ESC "[m" to revert to plain text.

The maximum size of a VMS prompt is 32 characters.  If your prompt would be
longer than 32 characters, the CD procedure truncates it to 29 characters
and attaches "..." to the end of it.  Keep in mind that if you use control
characters in your prompt, they count towards the maximum of 32.  If your
prompt is truncated, the command sequence to return the terminal to plain
text will not be sent.  Your terminal will stay bold (or reverse video, or
blinking, or underlined,...).  It's a good idea to use CD$CSI instead of
CD$ESC since you can have two more characters in your prompt.  But CD$CSI
is ignored by VT1xx terminals and terminals emulating a VT1xx includeing
VT2xx+ terminals.

The maximum number of "!AS"s you can have in the prompt format is 7.  This
also means that you are limited to 7 comma seperated parameters in
<prompt-params>.

If you start getting access violations after you try to create a prompt,
you have probably not provided the same number of "!AS" directives as you
did prompt parameters.  If you have 3 "!AS"s you need 3 parameters.  You
can keep CD from using your prompt information by deleting the symbols
with:

    $ DELETE/SYMBOL/GLOBAL PROMPT_FORMAT
    $ DELETE/SYMBOL/GLOBAL PROMPT_PARAMS

The CD procedure is available via anonymous FTP from CSTP.UMKC.EDU in the
[.COM] subdirectory in case any of your friends are interested in it.  It
is self-configuring so it can be put into any directory and should work on
any VMS V5.x+ system.  To use the procedure directly (without using the
SETUP CD) command, just activate it with the parameter SETUP:

    $ @CD.COM SETUP [<prompt-format> <prompt-params>]

The procedure will define the commands CD, PWD and BK for you and set your
prompt if you include the optional parameters.

For the brave and more inquisitive among you, COM$LIBRARY:CD_NEW.COM is the
name of the procedure and is available for your perusal.  <prompt-format>
is actually used in the procedure as a parameter to the lexical function
F$FAO ($ HELP LEX F$FAO <ret>) and <prompt-params> are the parameters for
the format.

Let me know if you have any questions, problems, or suggestions.  I'll be
updating the LOCALHELP sometime to reflect the new information.

Enjoy,

--Brian
