Reputation: 18113
PowerShell
prompt can be changed by calling
Function prompt{"new_prompt "}
and on the cmd
prompt can be changed by calling
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
. How can one make these changes permanent?
Upvotes: 4
Views: 2688
Reputation: 200193
For PowerShell you'd put your custom Prompt()
function in the relevant profile.
function Prompt {
"PS ${env:USERNAME}@${env:COMPUTERNAME} $(Get-Location)> "
}
For CMD you'd set/modify the PROMPT environment variable, e.g. via setx
:
setx PROMPT "%"USERNAME"%"@"%"COMPUTERNAME"%"$s$m$p$g$s
Upvotes: 7
Reputation: 36082
You have profile where you can put initialization for your PowerShell command prompts.
Type $profile
in your PowerShell command to see where it resides
Then modify it or create a new one if there doesn't exist one e.g. profile.ps1.
e.g. then add
function prompt { "PS " + $(get-date) ">"}
You can read more about profiles here
Upvotes: 3