TerminalBlocks.psm1

#Region '.\public\Exit-Prompt.ps1' 0
function Exit-Prompt {
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
        $global:LASTEXITCODE = [PoshCode.TerminalBlock]::LastExitCode
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Exit-Prompt.ps1' 4
#Region '.\public\Initialize-Prompt.ps1' 0
function Initialize-Prompt {
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
        [PoshCode.TerminalBlock]::LastSuccess = $global:?
    [PoshCode.TerminalBlock]::LastExitCode = $global:LASTEXITCODE
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Initialize-Prompt.ps1' 5
#Region '.\public\New-TerminalBlock.ps1' 0
function New-TerminalBlock {
    <#
        .Synopsis
            Create PoshCode.TerminalBlock with variable background colors
        .Description
            Allows changing the foreground and background colors based on elevation or success.
 
            Tests elevation fist, and then whether the last command was successful, so if you pass separate colors for each, the Elevated*Color will be used when PowerShell is running as administrator and there is no error. The Error*Color will be used whenever there's an error, whether it's elevated or not.
        .Example
            New-TerminalBlock { Show-ElapsedTime } -ForegroundColor White -BackgroundColor DarkBlue -ErrorBackground DarkRed -ElevatedForegroundColor Yellow
 
            This example shows the time elapsed executing the last command in White on a DarkBlue background, but switches the text to yellow if elevated, and the background to red on error.
    #>

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'New is not state changing!')]
    [OutputType([PoshCode.TerminalBlock])]
    [CmdletBinding(DefaultParameterSetName = "Content")]
    [Alias("TerminalBlock", "Block")]
    param(
        # The text, object, or scriptblock to show as output
        [AllowNull()][EmptyStringAsNull()]
        [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = "Content")] # , Mandatory=$true
        [Alias("InputObject")]
        $Content,

        # A special block that outputs just a newline (with no caps, ever)
        [Parameter(Mandatory, ParameterSetName = "Newline")]
        [switch]$Newline,

        # A special block that outputs an inverted Cap (to create gaps in PowerLine)
        [Parameter(Mandatory, ParameterSetName = "Spacer")]
        [switch]$Spacer,

        # A special block that stores the position it would have output at
        [Parameter(Mandatory, ParameterSetName = "StorePosition")]
        [switch]$StorePosition,

        # A special block that recalls to the position of a previous StorePosition block
        [Parameter(Mandatory, ParameterSetName = "RecallPosition")]
        [switch]$RecallPosition,

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    process {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "ProcessBlock", "Enter"
        try {
                switch($PSCmdlet.ParameterSetName) {
            Newline {
                $PSBoundParameters["Content"] = [PoshCode.SpecialBlock]::NewLine
                $null = $PSBoundParameters.Remove("Newline")
            }
            Spacer {
                $PSBoundParameters["Content"] = [PoshCode.SpecialBlock]::Spacer
                $null = $PSBoundParameters.Remove("Spacer")
            }
            StorePosition {
                $PSBoundParameters["Content"] = [PoshCode.SpecialBlock]::StorePosition
                $null = $PSBoundParameters.Remove("StorePosition")
            }
            RecallPosition {
                $PSBoundParameters["Content"] = [PoshCode.SpecialBlock]::RecallPosition
                $null = $PSBoundParameters.Remove("RecallPosition")
            }
        }

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach($name in [System.Management.Automation.PSCmdlet]::CommonParameters) {
            $null = $PSBoundParameters.Remove($name)
        }

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "ProcessBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "ProcessBlock", "Leave"
        }
    }
}
#EndRegion '.\public\New-TerminalBlock.ps1' 69
#Region '.\public\Show-AzureContext.ps1' 0
function Show-AzureContext {
    [Alias("AzureContextBlock","New-AzureContextBlock")]
    [CmdletBinding()]
    param(
        # A string to show before the output. Defaults to "$fg:32aee7&nf-mdi-azure;$fg:clear"
        $Prefix = "$fg:32aee7&nf-mdi-azure;$fg:clear",

        # Force imports the module if it's not imported
        # By default, this block only renders when Az.Accounts is imported.
        [switch]$Force,

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        # Force a default prefix
        $PSBoundParameters["Prefix"] = $Prefix
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    if ($Force -or (Get-Module Az.Accounts)) {
            if (($Context = Get-AzContext)) {
                $Context.Name
            }
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-AzureContext.ps1' 24
#Region '.\public\Show-Date.ps1' 0
function Show-Date {
    <#
        .SYNOPSIS
            Get the time span elapsed during the execution of command (by default the previous command)
        .DESCRIPTION
            Calls Get-History to return a single command and returns the difference between the Start and End execution time
    #>

    [OutputType([string])]
    [CmdletBinding(DefaultParameterSetName = "SimpleFormat")]
    param(
        # A DateTime format string such as "h\:mm\:ss". Defaults to "T"
        [Parameter(ParameterSetName = 'SimpleFormat')]
        [string]$Format = "T",

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    Get-Date -Format $Format
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-Date.ps1' 19
#Region '.\public\Show-DockerContext.ps1' 0
function Show-DockerContext {
    <#
        .SYNOPSIS
            Show the docker context
    #>

    [CmdletBinding()]
    param(
        # A string to show before the output. Defaults to "&whale;"
        [string]$Prefix = "&whale; ",

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        # Force a default prefix
        $PSBoundParameters["Prefix"] = $Prefix
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    if (Get-Command docker) {
            if (($Context = docker context show)) {
                $Context
            }
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-DockerContext.ps1' 23
#Region '.\public\Show-ElapsedTime.ps1' 0
function Show-ElapsedTime {
    <#
        .SYNOPSIS
            Get the time span elapsed during the execution of command (by default the previous command)
        .DESCRIPTION
            Calls Get-History to return a single command and returns the difference between the Start and End execution time
    #>

    [OutputType([string])]
    [CmdletBinding(DefaultParameterSetName = "SimpleFormat")]
    param(
        # A string to show before the output.
        [string]$Prefix = "&stopwatch;",

        # A Timespan format pattern such as "{0:ss\.fff}" defaults to "{0:d\d\ h\:mm\:ss\.fff}"
        # See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
        # See also: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
        [Parameter(ParameterSetName = 'SimpleFormat')]
        [string]$Format = "{0:d\d\ h\:mm\:ss\.fff}",

        # Automatically use different formats depending on the duration
        [Parameter(Mandatory, ParameterSetName = 'AutoFormat')]
        [switch]$Autoformat,

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        # Force a default prefix
        $PSBoundParameters["Prefix"] = $Prefix
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    $LastCommand = Get-History -Count 1
        if(!$LastCommand) { return "" }

        $Duration = $LastCommand.EndExecutionTime - $LastCommand.StartExecutionTime
        $Result = if ($Autoformat) {
            if ($Duration.Days -ne 0) {
                "{0:d\d\ h\:mm}" -f $Duration
            } elseif ($Duration.Hours -ne 0) {
                "{0:h\:mm\:ss}" -f $Duration
            } elseif ($Duration.Minutes -ne 0) {
                "{0:m\:ss\.fff}" -f $Duration
            } elseif ($Duration.Seconds -ne 0) {
                "{0:s\.fff}s" -f $Duration
            } elseif ($Duration.Milliseconds -gt 10) {
                ("{0:fff}ms" -f $Duration).Trim("0")
            } else {
                # 956 is μ (for microsecond), but Windows PowerShell has a hard time with UTF-8 unless there's a BOM, so this is for safety
                ("{0:ffffff}$([char]956)s" -f $Duration).Trim("0")
            }
        } else {
            $Format -f $Duration
        }
        $Result
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-ElapsedTime.ps1' 54
#Region '.\public\Show-ErrorCount.ps1' 0
function Show-ErrorCount {
    <#
        .SYNOPSIS
            Get a count of new errors from previous command
        .DESCRIPTION
            Detects new errors generated by previous command based on tracking last seen count of errors.
    #>

    [CmdletBinding()]
    param(
        # If set, always show the output
        [switch]$ShowZero,

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
            

    $Count = $global:Error.Count - $script:LastErrorCount
    $script:LastErrorCount = $global:Error.Count
    if ($ShowZero -or $Count -gt 0) {
        $Count
    }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-ErrorCount.ps1' 20
#Region '.\public\Show-HistoryId.ps1' 0
function Show-HistoryId {
    <#
        .SYNOPSIS
            Shows the ID of the command you're about to type (this WILL BE the History ID of the command you run)
    #>

    [CmdletBinding()]
    param(
        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor)end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
            
    $MyInvocation.HistoryId
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-HistoryId.ps1' 10
#Region '.\public\Show-KubeContext.ps1' 0
function Show-KubeContext {
    <#
        .SYNOPSIS
            Shows the current kubectl context
    #>

    [CmdletBinding()]
    param(
        # A string to show before the output. Defaults to "&nf-mdi-ship_wheel; "
        [string]$Prefix = "&nf-mdi-ship_wheel; ",

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        # Force a default prefix
        $PSBoundParameters["Prefix"] = $Prefix
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    if (Get-Command kubectl) {
            if (($Context = kubectl config current-context)) {
                $Context
            }
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-KubeContext.ps1' 23
#Region '.\public\Show-LastExitCode.ps1' 0
function Show-LastExitCode {
    <#
        .SYNOPSIS
            Show the LASTEXITCODE
        .DESCRIPTION
            Shows the exit code for native apps if the last command failed and left a LASTEXITCODE
 
            Can also show something for CommandNotFound or attmpt to execute a non-executable application
    #>

    [OutputType([string])]
    [CmdletBinding()]
    param(
        # A string to show before the output. Defaults to "&bomb;"
        [string]$Prefix = "&bomb;",

        # If you want to show a status even on successful commands, set this
        [string]$Success = "",

        # A string to show when a CommandNotFoundException is thrown.
        # Defaults to "🔍"
        [string]$NotFound = "&magnifyingglasstiltedleft;",

        # A string to show when an ApplicationFailedException is thrown.
        # This is typical for non-executable files on 'nix
        # Defaults to "🚫"
        [string]$NotExecutable = "&prohibited;",

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        # Force a default prefix
        $PSBoundParameters["Prefix"] = $Prefix
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    # If there was an error ...
        if (-not $? -or -not [PoshCode.TerminalBlock]::LastSuccess) {
            # We retrieve the InvocationInfo from the most recent error using $global:error[0]
            if ($LastError = $global:error[0]) {
                # If History[-1] matches Error[0].ErrorInvocationInfo then the last error was NOT a native command
                if ($LastError.InvocationInfo -and (Get-History -Count 1).CommandLine -eq $global:error[0].InvocationInfo.Line) {
                    if ($NotFound -and $LastError.Exception -is [System.Management.Automation.CommandNotFoundException]) {
                        $NotFound
                    } elseif ($NotExecutable -and $LastError.Exception -is [System.Management.Automation.ApplicationFailedException]) {
                        $NotExecutable
                    }
                } else {
                    if ([PoshCode.TerminalBlock]::LastExitCode -gt 0) {
                        [PoshCode.TerminalBlock]::LastExitCode.ToString()
                    } elseif ($global:LASTEXITCODE -gt 0) {
                        $global:LASTEXITCODE
                    }
                }
            }
        } elseif ($Success) {
            $Success
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-LastExitCode.ps1' 57
#Region '.\public\Show-Path.ps1' 0
function Show-Path {
    <#
        .SYNOPSIS
            Get a shortened version of a path for human readability
        .DESCRIPTION
            Trims the length of the path using various techniques
    #>

    [CmdletBinding(DefaultParameterSetName = "Length")]
    param(
        # Optionally, a strict maximum length of path to display
        # Path will be truncated to ensure it's shorter
        [Parameter(Position = 0)]
        [int]$Length = [int]::MaxValue,

        # Optionally, a strict maximum number of levels of path to display
        # Path will be truncated to ensure it's shorter
        [Parameter()]
        [int]$Depth = [int]::MaxValue,

        # Show the drive name on the front. Does not count toward length
        [switch]$DriveName,

        # A character to use for $Home. Defaults to "~"
        # You can use "&House;" to get 🏠 if you have Pansies set to EnableEmoji!
        # NOTE: this is based on the provider.
        # By default, only the FileSystem provider has a Home, but you can set them!
        [string]$HomeString = "~",

        # Only shows the path down to the root of git projects
        [switch]$GitDir,

        # Show only the first letter for all directories except the last one
        [Parameter()]
        [switch]$SingleLetterPath,

        # Show the first letter instead of truncating
        [Parameter()]
        [switch]$LeftoversAsOneLetter,

        # Optionally, turn it into a hyperlink to the full path.
        # In Windows Terminal, for instance, this makes it show the full path on hover, and open your file manager on ctrl+click
        [Parameter()]
        [switch]$AsUrl,

        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor
    )

    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    # If user passes 0 (or less), I just refuse to deal with it
        if ($Length -le 0 -or $Depth -le 0) {
            return [string]::Empty
        }

        [string]$Path = "$Pwd"
        $OriginalPath = $Path
        $resolved = Resolve-Path $Path
        $provider = $resolved.Provider

        $Drive = $resolved.Drive.Name + ":"
        $Path = $resolved.Path

        $BaseHome = $Provider.Home
        Write-Verbose "ProviderHome: $BaseHome"

        if ($GitDir -and "FileSystem" -eq $Provider.Name -and (Get-Command git)) {
            Push-Location $OriginalPath
            $toplevel = git rev-parse --show-toplevel 2>$null | Convert-Path
            Write-Verbose "GitDir: $TopLevel"
            Write-Verbose "Path: $Path"
            if (!$LASTEXITCODE -and $Path.StartsWith($TopLevel, "OrdinalIgnoreCase")) {
                $Path = $Path.SubString($TopLevel.Length)
                # If we're in a gitdir, we insist on showing it (using driveName logic)
                $Drive = Split-Path $TopLevel -Leaf
                $DriveName = $true
                $Depth = $Depth - 1
                Write-Verbose "Full: $Path"
            }
            Pop-Location
        }

        if ($Path) {
            if ($HomeString -and $BaseHome -and $Path.StartsWith($BaseHome, "OrdinalIgnoreCase")) {
                # If we're in $HOME, we insist on showing it (using driveName logic)
                $Drive = ''
                $DriveName = $false
                $Path = $HomeString + $Path.Substring($Home.Length)
            } else {
                $Path = Split-Path $Path -NoQualifier
            }

            if ($provider.ItemSeparator) {
                # Trust the provider's separator
                [PoshCode.Pansies.Text]$Path = $Path.Trim($provider.ItemSeparator)
                $Pattern = [regex]::Escape($provider.ItemSeparator)
                if (!$Separator) {
                    $Separator = $provider.ItemSeparator
                }
            } else {
                # Windows PowerShell
                [PoshCode.Pansies.Text]$Path = $Path.Trim("\")
                $Pattern = "\\"
                if (!$Separator) {
                    $Separator = "\"
                }
            }

            if ($SingleLetterPath) {
                # Remove prefix for UNC paths
                $Path = $Path -replace '^[^:]+::', ''
                $Folders = $Path -split $Pattern
                if ($Folders.Length -gt 1) {
                    # Supports emoji
                    $Folders = $Folders[0..($Folders.Count-2)].ForEach{ [System.Text.Rune]::GetRuneAt($_,0).ToString() } + @($Folders[-1])
                }
                $Path = $Folders -join $Separator
            } else {
                $Folders = $Path -split $Pattern
            }

            $Ellipsis = [char]0x2026

            if ($Path.Length -gt $Length -or $Folders.Length -gt $Depth) {
                [Array]::Reverse($Folders)
                # Start the path with just the last folder
                $Path, $Folders = $Folders
                $PathDepth = 1
                # If just the last folder is too long, truncate it
                if ("$Path".Length + 2 -gt $Length) {
                    Write-Verbose "$Path ($("$Path".Length) - $Length)"
                    $Path = $Ellipsis + "$Path".Substring("$Path".Length - $Length + 1)
                    if ($LeftoversAsOneLetter) {
                        $Folders = $Folders.ForEach{ [System.Text.Rune]::GetRuneAt($_,0).ToString() }
                        $Length = [int]::MaxValue
                    } else {
                        $Folders = @()
                    }
                }

                while ($Folders) {
                    $Folder, $Folders = $Folders

                    if ($Length -gt ("$Path".Length + $Folder.Length + 3) -and $Depth -gt $PathDepth) {
                        $Path = $Folder + $Separator + $Path
                    } elseif ($LeftoversAsOneLetter) {
                        # Put back the $Folder as well
                        $Folders = @(@($Folder) + $Folders).ForEach{ [System.Text.Rune]::GetRuneAt($_,0).ToString() } + @($Drive.Trim($provider.ItemSeparator, $Separator))
                        $Depth = $Length = [int]::MaxValue
                        $DriveName = $False
                    } else {
                        $Path = $Ellipsis + $Separator + $Path
                        break
                    }
                    $PathDepth++
                }
            } else {
                $Path = $Path -replace $Pattern, $Separator
            }
        }

        if ($DriveName) {
            if ($Path) {
                $Path = $Drive + $Separator + $Path
            } else {
                $Path = $Drive
            }
        }

        if ($AsUrl -and "FileSystem" -eq $Provider.Name) {
            $8 = "$([char]27)]8;;"
            "$8{0}`a{1}$8`a" -f $OriginalPath, $Path
        } else {
            $Path
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-Path.ps1' 174
#Region '.\public\Show-PoshGitStatus.ps1' 0
function Show-PoshGitStatus {
    <#
        .SYNOPSIS
            Shows the git status of the current working directory.
        .DESCRIPTION
            Calls PoshGit's Get-GitStatus & Write-GitStatus to display the git status
 
            Configure via $global:GitPromptSettings
    #>

    [OutputType([string])]
    [CmdletBinding()]
    param(
        [PoshCode.TerminalPosition]$Position,

        [PoshCode.BlockAlignment]$Alignment = "Left",

        [Alias("Prepend")]
        [String]$Prefix,

        [Alias("Suffix", "Append")]
        [String]$Postfix,

        # The separator character(s) are used between blocks of output by this scriptblock
        # Pass two characters: the first for normal (Left aligned) blocks, the second for right-aligned blocks
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [String]$Separator,

        # The cap character(s) are used on the ends of blocks of output
        # Pass two characters: the first for the left side, the second for the right side.
        [ArgumentCompleter({
                [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new(
                    [System.Management.Automation.CompletionResult[]]@(
                        # The Consolas-friendly block characters ▌and▐ and ╲ followed by all the extended Terminal cahracters
                        @([string[]][char[]]@(@(0xe0b0..0xe0d4) + @(0x2588..0x259b) + @(0x256d..0x2572))).ForEach({
                                [System.Management.Automation.CompletionResult]::new("'$_'", $_, "ParameterValue", $_) })
                    ))
            })]
        [PoshCode.BlockCaps]$Caps,

        # The foreground color to use when the last command succeeded
        [Alias("ForegroundColor", "Fg", "DFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultForegroundColor,

        # The background color to use when the last command succeeded
        [Alias("BackgroundColor", "Bg", "DBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$DefaultBackgroundColor,

        # The foreground color to use when the process is elevated (running as administrator)
        [Alias("AdminFg", "AFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminForegroundColor,

        # The background color to use when the process is elevated (running as administrator)
        [Alias("AdminBg", "ABg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$AdminBackgroundColor,

        # The foreground color to use when the last command failed
        [Alias("ErrorFg", "EFg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorForegroundColor,

        # The background color to use when the last command failed
        [Alias("ErrorBg", "EBg")]
        [AllowNull()][EmptyStringAsNull()]
        [PoshCode.Pansies.RgbColor]$ErrorBackgroundColor)
    dynamicparam {
        $Parameters = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
        if (Get-Module posh-git) {
            if ($global:GitPromptSettings) {
                foreach($Setting in $GitPromptSettings | Get-Member -Type Property) {
                    if ($Setting.Name -notin $MyInvocation.MyCommand.Parameters.Keys) {
                        # $Type = $GitPromptSettings.($Setting.Name).GetType()
                        $Type = $GitPromptSettings.GetType().GetProperty($Setting.Name).PropertyType
                        if ($Type -eq [bool]) {
                            $Type = [switch]
                        }

                        $param = [Management.Automation.RuntimeDefinedParameter]@{
                            Name          = $Setting.Name
                            ParameterType = $Type
                        }
                        $param.Attributes.Add(
                            [Parameter]@{
                                ParameterSetName = "__AllParameterSets"
                                Mandatory        = $false
                            }
                        )
                        # $param.Attributes.Add([ValidateSet]::new([String[]]@(...)))
                        $Parameters.Add($param.Name, $param)
                    }
                }
                $Parameters
            }
        }
    }
    # Use the BEGIN block for one-time setup that doesn't need to be re-calculated in the prompt every time
    begin {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Enter"
        try {
                        foreach($param in $PSBoundParameters.Keys) {
            if ($Parameters.ContainsKey($param)) {
                $global:GitPromptSettings.$param = $PSBoundParameters[$param]
            }
        }
        } catch {
            Write-Information $_ -Tags "BeginBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "BeginBlock", "Leave"
        }
    }
    # The end block will be turned into a closure and a TerminalBlock will be created
    end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
                $PSBoundParameters["Content"] = {
                    if (Get-Module posh-git) {
            Write-GitStatus (Get-GitStatus)
        }
        }.GetNewClosure()

        # Strip common parameters if they're on here (so we can use -Verbose)
        foreach ($name in @($PSBoundParameters.Keys.Where{$_ -notin [PoshCode.TerminalBlock].GetProperties().Name})) {
            $null = $PSBoundParameters.Remove($name)
        }

        $PSBoundParameters["MyInvocation"] = [System.Management.Automation.InvocationInfo].GetProperty("ScriptPosition", [System.Reflection.BindingFlags]"Instance,NonPublic").GetValue($MyInvocation).Text

        [PoshCode.TerminalBlock]$PSBoundParameters
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Show-PoshGitStatus.ps1' 58
#Region '.\public\Test-Elevation.ps1' 0
function Test-Elevation {
    <#
    .Synopsis
        Get a value indicating whether the process is elevated (running as administrator or root)
    #>

    [CmdletBinding()]
    param()end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
        
    [PoshCode.TerminalBlock]::Elevated
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Test-Elevation.ps1' 10
#Region '.\public\Test-Success.ps1' 0
function Test-Success {
    <#
    .Synopsis
        Get a value indicating whether the last command succeeded or not
    #>

    [CmdletBinding()]
    param()end {
        Write-Information "Enter $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Enter"
        try {
        
    [PoshCode.TerminalBlock]::LastSuccess
        } catch {
            Write-Information $_ -Tags "EndBlock", "Exception", "Unhandled"
            throw
        } finally {
            Write-Information "Leave $($PSCmdlet.MyInvocation.MyCommand.Name)" -Tags "EndBlock", "Leave"
        }
    }
}
#EndRegion '.\public\Test-Success.ps1' 10
#Region '.\Footer.ps1' 0
& {
    if (Get-Command Add-MetadataConverter -ErrorAction Ignore) {
        $AsConverters = @{}
        foreach($command in Get-Command Show-*, New-TerminalBlock -Module TerminalBlocks) {
            $AsConverters[$command.Name] = $command.ScriptBlock
        }
        Add-MetadataConverter $AsConverters
    }
}
#EndRegion '.\Footer.ps1' 10