Tag: Prompt

Changing your PowerShell Prompt

Ever had a PowerShell session when you are far down the folder path, and the prompt is so long it gets hard to see what commands and response you have…like this…

If only you could change the prompt to be a lot shorter…well, you can easily \o/

The PowerShell prompt is determined by the built-in Prompt function. You can customize the prompt by creating your own Prompt function and saving it in your PowerShell profile.

This sounds complicated, but the Prompt function is not protected, so to change the prompt for the current session only, just execute the function code as shown below, or with your own custom version and voila!

To make your custom prompt more permanent you need to save this to your PowerShell Profile. This means saving the function to the Power_profile.ps1 file in the appropriate location. Depending on the scope there are several locations, but I’m staying simple and changing mine for just me on my machine! 😉

  • Locations for Current user, Current Host are:
    • Windows – $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
    • Linux – ~/.config/powershell/Microsoft.Powershell_profile.ps1
    • macOS – ~/.config/powershell/Microsoft.Powershell_profile.ps1

For full information on Profiles see about Profiles – PowerShell | Microsoft Learn).

Very Short Prompt

This prompt just shows the Drive letter no matter where you are in the folders

function prompt {(get-location).drive.name+"\...>"}

This looks like this…

Screenshot of the terminal

My Preferred Shorter Prompt

This shows the Drive letter, ‘…’ for any intermediate folders and then just the last folder name, so you know your end destination.

function prompt {"PS " + (get-location).drive.name+":\...\"+ $( ( get-item $pwd ).Name ) +">"}

and looks like this…

Screenshot of the terminal

Reset back to the Default

Use this to set everything back to the original 🙂

function prompt {
    $(if (Test-Path variable:/PSDebugContext) { '[DBG]: ' }
      else { '' }) + 'PS ' + $(Get-Location) +
        $(if ($NestedPromptLevel -ge 1) { '>>' }) + '> '
}

For full details see about Prompts – PowerShell | Microsoft Learn

Getting IE to remember your login again, when you previously said don’t!

It’s very frustrating that IE will never prompt you again for saving details to a website once you have said ‘No’ in this prompt (in IE 9 it’s a bar along the bottom on the window!)

 

The easiest, but most destruction method of fixing this is to wipe all you form data using the options in IE.

However, I have found two good blogs that explain why and how to fix it without loosing all your other login details etc..

Firstly , a manual registry fix is explained here at watchingthenet.com. Using the registry editor you can do a three stage process to fix just the one website you have the problem with.

Secondly, there is this one by Eric Law that explains why it’s a bit tricky to resolve due to the secure storing of the form data and settings. Most importantly is that he has very kindly made a little utility that help you fix it for just one website at a time.

You need to put in the actual page address, not the domain. Best to go to the offending login page that is refusing to remember and copy the address directly.