CFOG's PIP, November 1987, Volume 6 No. 1, Whole No. 61, page 3

A Better Prompt from MS-DOS

by Rick Mattingly, KUAFC

[I found this article in the newsletter of the Pasadena, CA, Osbome group, OKOK. -- bhc]

After you've used your MS-DOS system for a while you will begin to want a bit more assistance from the computer. After all, that's what team spirit is all about, isn't it? There are numerous utility commands bulit into th MS-DOS operating system to provide this type of help. One of these is the "PROMPT" command. This command controls -- what else? -- the prompt! Instead of the plain old A> or C\> prompt, how about something a little more informative, such as: 12:07 A: \WORDSTAR>.

This prompt indicates the present time and that you are operating on drive A in a subdirectory named WORDSTAR (especially helpful if you're using a hard disk). The Prompt command has one parameter: PROMPT <string>, where <string> is any one or a combination of the following characters:

Character Produces
d current date
p current directory
n current drive
t current time
v DOS version number
g greater than sign
l less than sign
b vertical bar
q equals sign
e escape character
h backspace
$ dollar sign
_ end of line

To build a custom prompt you must remember one rule: each character which you use from the above list must be preceeded by a $ symbol. Thus to build the prompt string which would display the example give earlier, you would type the following from the normal system prompt

A>prompt $t$h$h$h$h$h$h $p $g
This Prompt command string says to display the current time ($t), the current directory ($p), and a greater than sign ($g). The $h sequence (six of them) backspace to wipe out the seconds display. The $t command will return not only the hours and minutes but also the seconds. Since in our example we did not want the seconds displayed, we would enter a $h (backspace erase) for each character and space involved (this has no effect at all on the speed with which the custom prompt will be displayed). Also, please note the spaces in the Prompt command tail. You must place a space where you want one to appear in the resulting custom layout

You can also create a custom prompt which uses multiple lines if you wish, such as the date and time on the first line and the current drive and directory in the second. This is done by placing a $_ <that's an underscore> in the command string where you wish the resulting prompt to break. To get really fancy you can take advantage of the fact that you can also enter any other characters or words you wish in the command line without a preceeding $ symbol. When a preceding $ symbol the following character(s) will be displayed literally. In this way you could get a prompt like: Your Wish is My Command.

To get back to your normal system prompt at any time just type PROMPT by itself and the good old reliable A> will return.

If you want to have your custom system prompt activated each time you boot up your system, put it in the AUTOEXEC.BAT file.