How do I change the command-line prompt into a console?
I've been looking in the console functions API, but I could not find anything for it.
How do I change the command-line prompt into a console?
I've been looking in the console functions API, but I could not find anything for it.
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.
prompt $P$_$G
. Once set with the prompt
command, it is set for future cmd shell windows. –
Stigmatism 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.
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.
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>
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:
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>
setx
saves persistent environment variables. They are saved to "HKEY_CURRENT_USER\Environment" for the current user, or "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" for all users (with the /M
flag). –
Diatessaron (base) E:\VSCodeProjects>
. I can temporarily change its color by doing set "PROMPT=$e[44m%PROMPT%$e[0m"
but it is only temporary. I guess it is not okay to set this to prompt
variable permanently because it changes all the time based on previous %PROMPT%
. –
Butlery 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.").
I found this article when searching for how to save the PROMPT command to always run when launching a command prompt. It works for any version of Windows.
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
.HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor
to apply the change to ALL users.If you want to save changes, used
setx prompt < format >
If you want to use it only one time
prompt < format >
Thanks years i didn't changed my prompt.
here a 2 lines prompt with path on first line some can be long and with colors, using this with black theme
set prompt=$E[36m%username%$E[31m@$E[36m%computername%$E[0m$G$P$_$E[32m$D$E[0m-$E[33m$T$E[0m$G
For more color / back ground can have a look to
in power shell can type it for you cession
function prompt {"PS $([char]0x1b)[36m$env:username$([char]0x1b)[31m@$([char]0x1b)[36m$env:computername$([char]0x1b)[0m $($PWD.ProviderPath)`n$([char]0x1b)[32m$(Get-Date)$([char]0x1b)[0m($NestedPromptLevel) >"}
To get it permanent, you will need to authorize scripts so up to you. Have a look here
for me Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser was enough
I use a batch file I call DOSbox.bat to set any environment strings I need, and I have a shortcut to it on my desktop. The command in the "Target:" box is C:\Windows\System32\cmd.exe /k DOSbox.bat. I have a Shortcut Key (Ctrl+Alt_D) to invoke it and the "Start in" set to my preferred directory. The shortcut also allows one to set the font, color, and location of the command window.
The contents of the batch file are currently:
@echo off
set dircmd=/ogne
prompt [$p]$_$g
The prompt shows the directory in brackets, and the ">" on a line by itself. This is useful for very long paths.
cmd
. Your method won't work in this workflow. AutoRun
in registry or simple setting PROMPT
environment variable as I described in my answer will work no matter how you execute the console. –
Stereoscope Shift
key pressed and click on "Open command window here". This works everywhere where you can open directory context menu. Also I have no clue what you mean by "Total Commander is not very universal". It's much more universal than Windows Explorer, which is not very useful for real work. –
Stereoscope © 2022 - 2025 — McMap. All rights reserved.
prompt _identifier_
in a cmd window. – Continuallyprompt _identifier_
: prompt | Microsoft Docs – Syllable