Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. function Prompt {
  2.  
  3. try {
  4. $history = Get-History -ErrorAction Ignore -Count 1
  5. if ($history) {
  6. Write-Host "[" -NoNewline
  7. $ts = New-TimeSpan $history.StartExecutionTime $history.EndExecutionTime
  8. switch ($ts) {
  9. {$_.TotalSeconds -lt 1} {
  10. [int]$d = $_.TotalMilliseconds
  11. '{0}ms' -f ($d) | Write-Host -ForegroundColor Black -NoNewline -BackgroundColor DarkGreen
  12. break
  13. }
  14. {$_.totalminutes -lt 1} {
  15. [int]$d = $_.TotalSeconds
  16. '{0}s' -f ($d) | Write-Host -ForegroundColor Black -NoNewline -BackgroundColor DarkYellow
  17. break
  18. }
  19. {$_.totalminutes -lt 30} {
  20. [int]$d = $ts.TotalMinutes
  21. '{0}m' -f ($d) | Write-Host -ForegroundColor Gray -NoNewline -BackgroundColor Red
  22. break
  23. }
  24. Default {
  25. $_.Milliseconds | Write-Host -ForegroundColor Gray -NoNewline
  26. }
  27. }
  28. Write-Host "]" -NoNewline
  29. }
  30. if(Get-Module Posh-git) {Write-VcsStatus}
  31. }
  32. catch { }
  33. # show the drive and then last 2 directories of current path
  34. if (($pwd.Path.Split('\').count -gt 2)){
  35. write-host "$($pwd.path.split('\')[0], '...', $pwd.path.split('\')[-2], $pwd.path.split('\')[-1] -join ('\'))" -NoNewline
  36. }
  37. else{
  38. Write-Host "$($pwd.path)" -NoNewline
  39. }
  40. "> "
  41. }
  42.  
  43. Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-9bda399\src\posh-git.psd1'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement