Are you getting less space on the PowerShell due to the long path of the current directory?

You can increase the signal to noise ratio by hiding that long path. How?

Follow the steps:

  • Navigate to PowerShell and type $profile.
  • It will give you a path to the PowerShell profile file.
  • Navigate to the directory of that PowerShell profile file.
    It was “C:\Users\{user}\Documents\WindowsPowerShell” for me.
  • Check if the file “Microsoft.PowerShell_profile.ps1” exists on the disk.
  • If NOT then create one “Microsoft.PowerShell_profile.ps1”.
  • Open “Microsoft.PowerShell_profile.ps1” file.
  • Paste the following code in it and save.
function prompt {
  $p = Split-Path -leaf -path (Get-Location)
  "$p> "
}
  • Restart PowerShell.
  • It will show the current folder name only.

One response to “How to make PowerShell shorten the long path of the current directory.”

  1. Carlos Herrera Avatar

    Thank you for sharing this code. Found exactly what I was looking for. Keep sharing such amazing articles in the future.

Leave a Reply

I’m Datta

Welcome to BeingCraftsman — where software architecture is treated as a long-term responsibility. I’m a Software Architect and Cloud Lead based in Pune, India, with over a decade of experience designing scalable systems, guiding teams, and making practical engineering decisions. This space is about clarity in architecture, reliability in systems, and leadership that helps teams build software that lasts.

Let’s connect

Linkedin

Discover more from Being Software Craftsman (DFTBA)

Subscribe now to keep reading and get access to the full archive.

Continue reading