General General General

Most Linuxes (i.e. Gentoo) will set your BASH prompt to the current working directory…which for BASH means only displaying the name of the deepest directory you're sitting in. PowerShell also defaults its prompt to the current working directory, but for PS that means returning the full path. What do you do if the directory you're in is “C:Documents and SettingsTest UserMy DocumentsSubversion ProjectsProject 1Development Branch”? Well, it ain't exactly pretty. There's no option within the get-location cmdlet that will return a “short” working directory (the default PS prompt uses get-location). So kemosabe, I proffer up this solution to acquiring a BASH-like working directory prompt in PowerShell:

  1. Create a directory called %DefaultUserProfile%My DocumentsWindowsPowerShell
  2. Inside your shiny new directory, create a file called profile.ps1 and place this code inside (if you already have a profile.ps1, just add this code to it):

function prompt
{
 ”PS ” + (get-location).Path.Split(“”)[(get-location).Path.Split("").Length -1] + “>”
}

As they say in the land of Brie…c'est tout. That's all folks. :-) Hopefully, this helps someone equally frustrated.

Technorati Tags: , , , ,