PoshCode Archive  Artifact [37d7b411ec]

Artifact 37d7b411eccabfb8c76625594b4b69791947f505d8a56ef44b2b16276b6356ef:

  • File LibraryPrompt.ps1 — part of check-in [ae854ebfb9] at 2018-06-10 13:06:49 on branch trunk — From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes (user: Lee Holmes size: 934)

# encoding: ascii
# api: powershell
# title: LibraryPrompt.ps1
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# type: function
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2193
# x-archived: 2016-03-19T00:34:01
# x-published: 2011-09-09T21:41:00
#
#
##############################################################################
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################

Set-StrictMode -Version Latest

function Prompt
{
    $id = 1
    $historyItem = Get-History -Count 1
    if($historyItem)
    {
        $id = $historyItem.Id + 1
    }

    Write-Host -ForegroundColor DarkGray "`n[$(Get-Location)]"
    Write-Host -NoNewLine "PS:$id > "
    $host.UI.RawUI.WindowTitle = "$(Get-Location)"

    "`b"
}