We all like to customize our PowerShell profile to our own needs, so there is no right or wrong in how to do this, but I’d like to show you mine nonetheless.
UPDATE: Kirk Munro (@Poshoholic) was good enough to point out that I had a bug in my path shortener, so in the process of rewriting it, I decided to do a small overhaul of my entire PowerShell Profile.
I start by saving the original PowerShell prompt. I then define my new custom prompt, as well as a third demo prompt. I created a short function (Set-Prompt) that I can use to change my prompt on the fly with the prompts I have predefined in my profile.
Next I have my new and improved path shortener, that now also works when using PowerShell providers like registry, variable etc.
I have also created a function that lets me open files for editing in Sublime Text, as well as an extension function of Get-Location (that I later use when overriding the pwd alias further down).
I also converted my old code to check if the current user is running as admin to a function instead.
Next are my alias definitions, followed by setting the new prompt, my custom location and updating my environment variables.
Lastly I load my modules. I have included a check for ISE so that I can use the same profile for both ISE and the normal host.
That’s it. Any comments and suggestions are always welcome!