Skip to content

Instantly share code, notes, and snippets.

View HerbM's full-sized avatar

Herb Martin HerbM

  • LearnQuick.Com
  • Austin, TX
View GitHub Profile
@HerbM
HerbM / gist:abd73225cb2dd796350623a928b51e74
Created April 1, 2018 13:28
Old Prompt (2018 Mar 30)
Function Global:prompt {
If (!(Get-Variable MaxPrompt -ea 0 2>$Null)) { $MaxPrompt = 45 }
$loc = "$($executionContext.SessionState.Path.CurrentLocation)"
$Sig = " |>$('>' * $nestedPromptLevel)"
if ($Global:MaxPromptLength) {
$LocLen = $Loc.length; $SigLen = $Sig.Length
$Length = $LocLen + $SigLen
$Excess = $Length - $Global:MaxPromptLength
If ($Excess -gt 0) {
$Excess = [Math]::Min($Excess, $LocLen)
Function Get-CurrentLineNumber {
$Invocation = Get-Variable MyInvocation -value -ea 0 2>$Null
If (!$Invocation) { $Invocation = $MyInvocation }
$Invocation.ScriptLineNumber
}
Function Get-CurrentFileLine {
if ($MyInvocation.PSCommandPath) {
"$(split-path -leaf $MyInvocation.PSCommandPath):$($MyInvocation.ScriptLineNumber)"
} else {"GLOBAL:$(LINE)"}
Function Get-Property {
[CmdletBinding()]param(
[Parameter(ValueFromPipeline)][psobject]$object,
[switch]$AsHash
)
Process {
If ($AsHash) {
$Property = [ordered]@{}
$Object.psobject.get_properties() | ForEach-Object {
$Property += @{ $_.Name = $_.Value }