Modifier Prompt Powershell – Fonction pour ajouter dossier / sous dossier

Un bout de code intéressant, voir indispensable 😉

[codesyntax lang=”powershell”]

function prompt {
 $cwd = (get-location).Path

[array]$cwdt=$()
$cwdi=-1
do {
$cwdi=$cwd.indexofany(”\\”,$cwdi+1)
[array]$cwdt+=$cwdi} until($cwdi -eq -1)

if ($cwdt.count -gt 3) {
$cwd = $cwd.substring(0,$cwdt[0]) + “\..” + $cwd.substring($cwdt[$cwdt.count-3])
}

” $cwd>_ ”
}
# The above sets prompt to the current drive letter, immediate sub directory and current directory.
#     Example: C:\..\drivers\etc>_

Import-Module Pscx #-arg ~\Pscx.UserPreferences.ps1

[/codesyntax]