[英]How to Permanently change PowerShell and CMD prompts
PowerShell
prompt can be changed by calling 可以通过调用来更改
PowerShell
提示符
Function prompt{"new_prompt "}
and on the cmd
prompt can be changed by calling 并且可以通过调用更改
cmd
提示符
prompt $g$g$s
Once the current window is closed all the changes are gone and one will have to change them again when opening new instances of PowerShell
or cmd
. 关闭当前窗口后,所有更改都将消失,并且在打开
PowerShell
或cmd
新实例时,必须再次更改它们。 How can one make these changes permanent? 如何让这些变化永久化?
For PowerShell you'd put your custom Prompt()
function in the relevant profile . 对于PowerShell,您可以将自定义
Prompt()
函数放在相关的配置文件中 。
function Prompt {
"PS ${env:USERNAME}@${env:COMPUTERNAME} $(Get-Location)> "
}
For CMD you'd set/modify the PROMPT environment variable, eg via setx
: 对于CMD,您可以设置/修改PROMPT环境变量,例如通过
setx
:
setx PROMPT "%"USERNAME"%"@"%"COMPUTERNAME"%"$s$m$p$g$s
You have profile where you can put initialization for your PowerShell command prompts. 您有配置文件,您可以在其中为PowerShell命令提示进行初始化。
Type $profile
in your PowerShell command to see where it resides 在PowerShell命令中键入
$profile
以查看它所在的位置
Then modify it or create a new one if there doesn't exist one eg profile.ps1. 然后修改它或创建一个新的,如果不存在例如profile.ps1。
eg then add 例如然后添加
function prompt { "PS " + $(get-date) ">"}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.