Make your Windows PowerShell Prompt Look Like your bash Prompt

Being a Linux admin at heart I want my Windows Powershell prompt to look like my bash prompt (yep, I'm a nerd, or OCD, or may a little of both).

What you'll need to do is place some code in your Powershell profile file. By default Powershell doesn't allow scripts to run unless they're signed. This is good security practice. There are many articles out there on how to sign your Powershell scripts and maybe one day I'll write one and put it up here on the I.T. Nerve Center, but for now I'll just give you the code to change your prompt.

This Microsoft TechNet article will help you find the Powershell profile file going from least specific to most specific - http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx - Once you pick which file you want to use just add the following code:


function prompt {


"[$env:username@$([System.Net.Dns]::GetHostName()) $(Get-Location)]$ "


}

Watch the wrapping. the env:username code should all be on one line

Your PS prompt will now look like your bash prompt. Experiment to change it to your liking.

Enjoy,
Flux.

Wow, thanks! :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.