line prompt in Windows?
How to change the command-line prompt into a console?
I've been looking for in the console functions API but I could not find anything for it.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx
There's the PROMPT environment variable:
set PROMPT=$P$G
is the default value, giving you the usual C:>
type output. There's more format variables available here.
The command is:
prompt yourPrompt
the full list of options is at:
https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prompt.mspx?mfr=true
Another possibility is to set PROMPT
environment variable (what's in fact what the prompt
command is doing).
The advantage of this method is that you can easily set it system-wide and you don't need any scripts, edit registry etc. It will work for any console window no matter how you open it.
You can do it using 2 methods, GUI and command-line.
1. GUI method
Simply press Win + Pause/Break (open System properties), click Advanced system settings, Environment variables and create new user or system variable named PROMPT
with value set to whatever you want your prompt to look like. 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>
It will do the same as previous method - create a PROMPT
key in the registry hive HKEY_CURRENT_USEREnvironment
. If you want to set it for all users, just add /M
switch:
setx PROMPT <your-prompt-format> /M
It will create a PROMPT
key in the registry hive HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
.
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), to read the new or changed environment variable. If you can't do it for whatever reason, you can use the following method:
3. 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>
链接地址: http://www.djcxy.com/p/85040.html
上一篇: 如何在Windows上使用Vim中开发者命令提示符的命令行?
下一篇: 在Windows提示行?