How do I change the command-line prompt in Windows?

Using HELP:

C:\Windows-15:21:07.12> help PROMPT

Changes the cmd.exe command prompt.

PROMPT [text]

  text    Specifies a new command prompt.

Prompt can be made up of normal characters and the following special codes:

  $A   & (Ampersand)
  $B   | (pipe)
  $C   ( (Left parenthesis)
  $D   Current date
  $E   Escape code (ASCII code 27)
  $F   ) (Right parenthesis)
  $G   > (greater-than sign)
  $H   Backspace (erases previous character)
  $L   < (less-than sign)
  $N   Current drive
  $P   Current drive and path
  $Q   = (equal sign)
  $S     (space)
  $T   Current time
  $V   Windows version number
  $_   Carriage return and linefeed
  $$   $ (dollar sign)

If Command Extensions are enabled, the PROMPT command supports
the following additional formatting characters:

  $+   zero or more plus sign (+) characters depending upon the
       depth of the PUSHD directory stack, one character for each
       level pushed.

  $M   Displays the remote name associated with the current drive
       letter or the empty string if the current drive is not a network
       drive.

Reference for "Command Extensions" (e.g. "Command Extensions are enabled by default.").


There's the PROMPT environment variable:

set PROMPT=$P$G

$P$G is the default value, giving you the usual C:\> type output. There are more format variables available here.


Another possibility is to set the PROMPT environment variable (which in fact is what the PROMPT command does).

The advantage of this method is that you can easily set it system-wide and you don't need any scripts, edit the Windows Registry, etc. It will work for any console window no matter how you open it.

You can do it using two methods, GUI and command-line.

1. GUI method

Simply press Win + Pause/Break (open System properties), click Advanced system settings, Environment variables and create a new user or system variable named PROMPT with the value set to whatever you want your prompt to look like. A system variable will set it for all users.

You can see it with pictures in this article.

2. Command-line method

Another way to set the PROMPT environment variable permanently is to use the SETX command:

setx PROMPT <your-prompt-format>

If you want to set it for all users, just add the /M switch:

setx PROMPT /M <your-prompt-format>

3. Registry method

In fact, both previous methods just create a string value named PROMPT in the registry. For the current user, it's under the key HKEY_CURRENT_USER\Environment, and the system-wide one for all users under the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.


Check this page or other answers for details about the prompt format.

Note: it's possible that you will have to reboot your system (or possibly just sign out and in) for the changes to take effect. At least, you have to close and restart the application (console), so it loads the new or changed environment variable. If you can't do it for whatever reason, you can use the following method:

4. Command-line method (temporary)

If you execute the PROMPT command, it will set the PROMPT environment variable in your local context, so it will take an effect immediately, but until the console is closed only. It's not stored permanently.

prompt <your-prompt-format>