Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shortening the PowerShell Prompt

Customizing PowerShell

Shortening the PowerShell Prompt

by  markdmac  Posted    (Edited  )
Greetings PowerShell Enthusiasts!

I’m practically bouncing off the walls (I am so easily amused) over a new profile change I just made. I’ve added this to both my ISE and non ISE PowerShell profiles. What this will do is keep your display prompt at PS> and the top of the window will then show your current location. No longer do you need to suffer through a prompt that is ever growing in length as you change directories.

To access your profile easily to add this code at the end, simply open PowerShell or PowerShell_ISE and at the prompt type NotePad $Profile and press enter. Paste this code at the bottom of the profile page and save it.


[code PowerShell]
function prompt
{
'PS> '
$host.UI.RawUI.WindowTitle = Get-Location
}
[/code]
Close and re-open PowerShell and do a happy dance when you see how your prompt now behaves.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top