FullPath Pain with PowerShell

·

1 min read

My folder structures were getting deeper and deeper and the full path prior to the caret for Windows PowerShell was taking up most of the initial line.

After a little bit of research and I found the solution to this for me.
My Solution: Show the current folder name prior to the prompt

Open the folder C:\Users*UserAccountName*
      Drill down into: \Documents\WindowsPowerShell\
      Edit the file: Microsoft.PowerShell_profile.ps1

This file may be empty or as in my case the file did not exist.

Using a text editor I created this file and added the following code

function prompt {
  $p = Split-Path -leaf -path (Get-Location)
  "$p> "
}

Saved the file and reopened PowerShell.
This gave me the result I wanted.

Note:
Just delete the code from the file or the whole file (if you want) and this will return PowerShell back to it's default setting.