PoshCode Archive  Artifact [08541ccdb2]

Artifact 08541ccdb2b50bb72d40a3ac785338a3ae53ff80847f26c706ca4dbb66eaa52a:

  • File LibraryPrompt.ps1 — part of check-in [0a23b15d50] at 2018-06-10 13:45:37 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: 4774
# x-archived: 2016-03-18T21:49:10
# x-published: 2016-01-06T23:50: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"
}