Command prompts

You've come to this page because you've asked about command prompts.

This is the Frequently Given Answer to such questions.

A command prompt is the prompt that is displayed by a command interpreter. It is not a "DOS prompt".

A command prompt is displayed by the particular command interpreter that one is running at the time. Many command interpreters use the value of the PROMPT environment variable to determine what they display as a prompt. The value of the variable comprises literal text interspersed with special codes that the command interpreter expands, on the fly each time that it issues a prompt, to various strings. The result, after expansion, is what is displayed as the prompt.

The various substitutions that the 32-bit Command Interpreter makes to the value of the PROMPT environment variable
String Substitution
$$The $ (dollar) character
$A or $aThe & (ampersand) character
$B or $bThe | (bar) character
$C or $cThe ( character
$DThe date in standard ISO 8601 form
$dThe date in the current country's local form
$E or $eThe escape character (ASCII 27)
$F or $fThe ) character
$G or $gThe > (greater than) character
$H or $hThe backspace character (ASCII 8)
$I or $iThe help banner
$L or $lThe < (less than) character
$MThe time in HH:MM form
$mThe time in HH:MM:SS xm form (12-hour)
$N or $nThe drive letter of the current drive
$P or $pThe current directory on the current drive
$Q or $qThe = (equals) character
$R or $rThe return value of the most recent command
$S or $sThe space character (ASCII 32)
$TThe time in standard ISO 8601 form
$tThe time in the current country's local form
$UThe timezone as an offset from UTC
$uThe timezone name
$V or $vThe command interpreter and operating system version
$Xd or $xdThe current directory on the drive 'd'
$_A carriage return and line-feed

There is significant variation in how command interpreters interpret the value of the PROMPT environment variable. For example: Most of the (textual user interface) command interpreters for OS/2, both the ones that are native OS/2 applications and the ones that are DOS applications, understand the $I sequence, which causes them to display a banner across the top of the console. This is the banner that IBM's 16-bit CMD displays, for example:

OS/2  Ctrl+Esc = Window List    Type HELP = help

[C:\]

However, this banner it isn't displayed by graphical user interface command interpreters on OS/2, and the $I string is not understood at all by any command interpreters for Windows NT.

In the absence of that environment variable, command interpreters display a default prompt. This also varies from command interpreter to command interpreter. These are the default prompts for several command interpreters:


© Copyright 2007,2009 Jonathan de Boyne Pollard. "Moral" rights asserted.
Permission is hereby granted to copy and to distribute this web page in its original, unmodified form as long as its last modification datestamp is preserved.