I'm using PowerShell on Windows 7. How can I configure PowerShell so that it only displays the current folder name (instead of the full path) in the shell prompt?
For example, instead of C:\folder\directory\name>
, I want name>
.
powershellwindows 7
I'm using PowerShell on Windows 7. How can I configure PowerShell so that it only displays the current folder name (instead of the full path) in the shell prompt?
For example, instead of C:\folder\directory\name>
, I want name>
.
Best Answer
You have to customize the prompt function in your PowerShell profile (
%userprofile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
); it may be blank or even not exist if you have never modified it before.Open your profile (e.g., open the aforementioned file or while in PowerShell,
Notepad $profile
)Add the following to your profile:
Save the profile
Restart PowerShell
Optional. If you get a message that says you are not allowed to run scripts, then you need to copy/paste this line in PowerShell:
and restart.