|
Re: Prompt "dance2die" <dance2die@discussions.microsoft.com> wrote in message
news:A7EAA3A1-2C45-47E1-9FF5-938B14F09C50@microsoft.com...
>
> function prompt
> {
> # display Computer name, username and the date time
> write-host -NoNewLine "[$($env:ComputerName)] [$($env:UserName)]
> $(get-date)`n"
> # Add a logic for displaying Network path for Network drive
> # not implemented...
>
> # display current working directory
> write-host -NoNewLine "$(pwd)`n"
>
> # display Stack level
> Write-Host -NoNewLine ("+" * ((Get-Location -Stack).count))
> ">"
> }
I think the idea of the prompt function is to return a string that
PowerShell then writes to the host. So you might modify this to:
function prompt
{
$prompt = "[$($env:ComputerName)] [$($env:UserName)] $(get-date)`n"
$result = net use "$($pwd.drive):" 2> $null
if ($?) {
$result[1] -match "Remote name\s+(?<name>.*)" > $null
$matches.name + " "
}
$prompt + $(pwd)`n
$prompt += "+" * ((Get-Location -Stack).count
$prompt += "> "
$prompt
}
--
Keith |