Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows PowerShell: changing the command prompt

Using Windows PowerShell, how do I change the command prompt?

For example, the default prompt says

PS C:\Documents and Settings\govendes\My Documents> 

I want to customize that string.

like image 495
sashang Avatar asked Apr 20 '11 05:04

sashang


People also ask

Can PowerShell replace cmd?

To create the best command-line experience, PowerShell is now the command shell for File Explorer. It replaces Command Prompt (cmd.exe) in the Windows Logo Key + X menu, in File Explorer's File menu, and in the context menu that appears when you shift-right-click the whitespace in File Explorer.


1 Answers

Just put the function prompt in your PowerShell profile (notepad $PROFILE), e.g.:

function prompt {"PS: $(get-date)>"} 

or colored:

function prompt {     Write-Host ("PS " + $(get-date) +">") -nonewline -foregroundcolor White     return " " } 
like image 200
Ocaso Protal Avatar answered Sep 27 '22 21:09

Ocaso Protal