Purpose:Change the command line prompt


Format:PROMPT [text]


text  Text to be used as the new command line prompt.


See also:   ESET and SET (the PROMPT command is syntactically equivalent to SET PROMPT).




You can change and customize the command line prompt at any time. The prompt can include normal text and system information such as the current drive and directory, the time and date, and the amount of memory available. You can create an informal "Hello, Bob!" prompt or a complex prompt full of impressive information.


The prompt text can contain special commands in the form $?, where ? is one of the characters listed below. Unless otherwise specified, those meta characters are case-independent.


aThe ampersand character[&].
bThe vertical bar character [|].
cThe open parenthesis [(].
dCurrent date, in the format: Fri  01-01-20 (the month, day, and year are formatted according to your current country settings)
DCurrent date, in the format: Fri  Aug 19, 2018
eThe ASCII ESC character (decimal 27), necessary for ANSI commands.
fThe close parenthesis [)].
gThe > character.
hBackspace over the previous character.
jCurrent date in ISO 8601 format (yyyy-mm-dd).
lThe < character.
mTime in hours and minutes using 24-hour format.
MTime in hours and minutes using the default country format.
nCurrent drive letter.
pCurrent drive and directory (lower case).
PCurrent drive and directory (upper case on drives which do not support long filenames; directory names shown in mixed case as stored on the disk on LFN drives).
qThe = character.
rThe numeric exit code of the last external command.
sThe space character.
tCurrent 24-hour time, in the format hh:mm:ss.
TCurrent 12-hour time, in the format hh:mm:ss[a|p).
uThe current user.
vWindows version number, in the format 6.0.
wCurrent directory, in a shortened format. If the current directory is the root or a first-level subdirectory, it is displayed as-is. If it is second level or deeper, the path is truncated (i.e., "c:\...\config"). (This does not work with UNC names.)  $W and $w behave like $P and $p for displaying upper/lower case.
xd:Current directory on drive d: in lower case, including the drive letter (uses the actual case of the directory name as stored on the disk for LFN drives.)
Xd:Current directory on drive d: in upper case, including the drive letter.
zCurrent shell nesting level.
+Display one + character for each directory on the PUSHD directory stack.
$The $ character.
$:Display the prompt timer (in hh:mm:ss format).
_CR/LF (go to beginning of a new line).
~(Substitute for P). If the environment variable HOME (or HOMEDRIVE + HOMEPATH) exists, TCC will compare the variable to the beginning of the current path. If they match, TCC will substitute ~ for the variable part. (If they don't match, ~ is treated like a P.)
=The elapsed time (in milliseconds) since the previous command was started.
"..."Display the current date / time in a custom format. The formatting characters enclosed in double quotes are the same as those used by the @DATEFMT function.
/Host name
@Computer name
#User name
?Last error level for an internal command


For example, to set the prompt to the current date and time, with a ">" at the end:


[c:\] prompt $d $t $g

Mon  Feb 24, 2020 10:29:19 >


To use the ~ (home) metacharacter:


[c:\] set home=c:\users\myself

[c:\] set prompt=[$~]

[c:\] cd \users\myself\downloads



The TCC prompt can be set in TCSTART or in any batch file that runs when TCC starts.


If you enter PROMPT with no parameters, the prompt will be reset to its default value.


You can include literal text and special characters as well as the value of any environment variable, internal variable, or variable function in a prompt. For example, if you want to include the size of the largest free memory block in the command prompt, plus the current drive and directory, you could use this command:


[c:\] prompt [(%%@dosmem[K]K) $p]

[(31043K) c:\data]


Notice that the @DOSMEM function is shown with two leading percent signs [%]. If you used only one percent sign, the @DOSMEM function would be expanded at once when the PROMPT command was executed, instead of every time the prompt is displayed. As a result, the amount of memory would never change from the value it had when you entered the PROMPT command. You can also use back quotes to delay expanding the variable function until the prompt is displayed:


prompt `[(%@dosmem[K]K) $p]`


You can use this feature along with the @EXEC variable function to create a complex prompt which not only displays information but executes commands. For example, to execute an alias which checks battery status each time the prompt is displayed (enter the alias on one line):


alias cbatt `if %_apmlife lt 30 beep 440 4 880 4 440 4 880 4`

prompt `%@exec[@cbatt]$p$g`


You can include ANSI escape sequences in the PROMPT by using the built-in ANSI X3.64 support in TCC. This example uses ANSI X3.64 sequences to set a prompt that displays the shell level, date, time and path in color on the top line of the screen (enter the command as one line):


prompt $e[s$e[1;1f$e[41;1;37m$e[K[$z] $d  

Time: $t$h$h$h  Path: $p$e[u$e[0;32m$n$g