ARCHIVED: In DOS, how can I modify my prompt or the screen color?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

Note: The software discussed here is no longer in common use at IU, and UITS may no longer be able to verify this text's accuracy; additionally, the UITS Support Center may no longer have the materials needed to adequately support this software.

You can use the prompt command to personalize the DOS prompt. The format of the command is:

  prompt text

where text is a line of text that specifies the format of the prompt.

Changing Prompt Information

Place the following special codes in the text string to produce special information or characters:

Code Result
$_ Enter/Linefeed
$$ Dollar sign
$b | (pipe)
$d Current date
$e ASCII escape code (code 27)
$g > (greater-than sign)
$h Backspace
$l < (less-than sign)
$n Current drive
$p Current drive and path
$q = (equal sign)
$t Current time
$v DOS version number

For example, a typical use of the prompt command is:

  prompt $p$g

This produces a prompt that consists of the current drive and path followed by a greater-than sign. Once you have found a prompt that you like, you should include the prompt command that produces it as an entry in your AUTOEXEC.BAT file, located in the root directory.

Changing Colors

If you wish to produce text of different colors, you will need to install the ANSI screen driver. Make sure that the file ANSI.SYS exists on your hard drive and is correctly referenced in an entry in your CONFIG.SYS file, similar to the following:

  DEVICE = C:\DOS\ANSI.SYS

The above example assumes that the ANSI.SYS file is located in your DOS directory on the C: drive. Replace the drive letter and/or path information as necessary on your own computer.

Note: ANSI.SYS replacements such as NANSI.SYS or FCONSOLE.DEV may also work, but may be incompatible with some software.

You can change the colors of the text in the DOS prompt (and the color attributes of the screen) using the following escape sequence:

  $e[xx;yy;zzm

where xx = attribute code, yy = foreground color code, and zz = background color code.

A table of the color codes follows:

Code Color
0 Turn Off Attributes
1 High Intensity
2 Normal Intensity
4 Underline (mono only)
5 Blink
7 Reverse Video
8 Invisible
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White

For example, the following command will result in a bright red C:\> prompt and bright yellow text on a blue background.

  C:\> prompt $e[1;31;44m$p$g$e[1;33;44m

Including color specifications in the prompt command changes not only the color of the prompt, but also the color of other text that you type or display. In the above example, the prompt will appear red, but other text will show up as yellow on blue.

Sample Prompts

For some interesting prompts, cut and paste as entries in your AUTOEXEC.BAT file one of the following command lines that begin with the prompt command:

GO IU!:

  prompt $e[5;37GOm$e[5;31mIU$e[0;33m$p$g

Merry Christmas:

  prompt $e[1;5;37m  *$_$e[0;32;40m  1$_ $e[1;31;42m u $_$e[33;42m
  x o $e[30;40m$e[K$_  _$_$e[31m MERRY$_CHRISTMAS!$_$e[37m$p$g

Jack o' Lantern:

  prompt $e[1;32;40m  Z$_$e[33;43m   $e[40m$e[K$_$e[43m    $_
  __ $e[37;40m$e[37;40m$e[K$_ BOO!$_$_$e[35m  $p$g$e[37m

Choo choo train:

  prompt
  $e[44;37;5m$e[16C$e[0;44;1;31m$_111$e[36m111$e[31m111$e[3
  5m11 1\]$_$e[32;5mx x x x x x   x$e[0;1;44;37m$e[1A$p$g

This is document aamm in the Knowledge Base.
Last modified on 2018-01-18 08:50:34.