Command prompt

From Wikipedia, the free encyclopedia
Jump to: navigation, search
This article is about the topic of "command prompts". For specific command prompt implementations, see List of command-line interpreters.

A command prompt is a kind of prompt, that is a message from a computer system asking the user to do something or to provide information.[1] Prompts are sequences of one or more characters used in a command-line interface to indicate its readiness to accept commands. Prompts may vary from one command interpreter to another, but usually ends with a special character such as $, %, #, :, > and often includes other information, such as the path of the current working directory.

On many Unix system and derivative systems, it is common for the prompt to end in a $ or % character if the user is a normal user, but in a # character if the user is a superuser ("root" in Unix terminology).

It is common for prompts to be modifiable by the user. Depending on the environment, they may include colors, special characters, and other elements like variables and functions for the current time, user, shell number or working directory, in order, for instance, to make the prompt more informative or visually pleasing, to distinguish sessions on various machines, or to indicate the current level of nesting of commands. On some systems, special tokens in the definition of the prompt can be used to cause external programs to be called by the command-line interpreter while displaying the prompt.

COMMAND.COM is the default command-line interpreter in DOS and Windows 9x operating systems, while CMD.EXE, the default command-line interpreter in OS/2 and Windows NT operating systems. Console Command Processor (CCP) is the command-line interpreter in the CP/M and MP/M family of operating systems. In DOS's COMMAND.COM and in the Windows NT's command-line interpreter CMD.EXE the prompt is modifiable by issuing a prompt command or by directly changing the value of the corresponding %PROMPT% environment variable. The default of most modern systems, the C:\> style is obtained, for instance, with "prompt $P$G". The default of older DOS systems, C> is obtained by just "prompt", although on some systems this produces the newer C:\> style, unless used on floppy drives A: or B:; on those systems "prompt $N$G" can be used to override the automatic default and explicitly switch to the older style.

On many Unix systems, the $PS1 variable can be used, although other variables also may have an impact on the prompt (depending on what shell is being used). In the bash shell, a prompt of the form

[time] user@host: work_dir $

could be set by issuing the command

export PS1='[\t] \u@\H: \W $'

In zsh the $RPROMPT variable controls an optional "prompt" on the right hand side of the display. It is not a real prompt in that the location of text entry does not change. It is used to display information on the same line as the prompt, but right justified.

In RISC OS, the command prompt is a '*' symbol, and thus (OS)CLI commands are often referred to as "star commands".[2] It is also possible to access the same commands from other command lines (such as the BBC BASIC command line), by preceding the command with a '*'.


  1. ^ Merriam-Webster. "prompt". Retrieved July 27, 2014. 
  2. ^ RISC OS 3 User Guide, Part 3: Outside the desktop (page 125) Published by Acorn Computers Limited, , Edition 2 Part number 0496,075 Issue 1 March 1992

See also[edit]