Advertisement
Old-Lost

My prompt function

Jun 12th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function prompt {
  2.     [string]$TimeString = (Get-History -Count 1).ElapsedTime
  3.     while ($TimeString -match '\A00([-:]|\z)') { $TimeString = $TimeString -replace '\A00([-:]|\z)' }
  4.     if ($TimeString) { Write-Host "$TimeString " -NoNewline -ForegroundColor Red }
  5.     Write-Host ($executionContext.SessionState.Path.CurrentLocation.Path -replace '(.+?\\.+?\\).+?(\\[^\\]*)\z', '$1...$2') -NoNewline -ForegroundColor Cyan
  6.     Write-Host ('>' * ($NestedPromptLevel + 1)) -NoNewline -ForegroundColor Gray
  7.     return " "
  8. } # prompt
  9.  
  10. Update-TypeData -Force -TypeName Microsoft.PowerShell.Commands.HistoryInfo -MemberType ScriptProperty -MemberName ElapsedTime -Value {
  11.     ([timespan]($this.EndExecutionTime - $this.StartExecutionTime)).ToString('dd\-hh\:mm\:ss')
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement