Last active
June 17, 2018 12:47
-
-
Save henriksen/b65ba022050ffc0ff31d7e668570279b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
Function Get-LastCommandExecutionTime { | |
<# | |
.SYNOPSIS | |
Gets the execution time of the last command used. | |
.EXAMPLE | |
Get-LastCommandExecutionTime | |
Description | |
----------- | |
Gets the last execution time of the last command run. | |
#> | |
Process { | |
Try { | |
(Get-History)[-1].EndExecutionTime - (Get-History)[-1].StartExecutionTime | |
} | |
Catch { | |
[timespan]::fromseconds(0); | |
} | |
} | |
} | |
[...] | |
function prompt { | |
$lastExecutionTimeSpan = Get-LastCommandExecutionTime | |
$lastExecutionTime = "{0}{1}{2:00}s" -f $(if ($lastExecutionTimeSpan.TotalMinutes -ge 1.0d) | |
{"$([Math]::Floor($lastExecutionTimeSpan.TotalMinutes))m "} else {""}), | |
$(if ($lastExecutionTimeSpan.TotalMilliseconds -lt 1000) { ">"} else {""}), | |
$(if ($lastExecutionTimeSpan.TotalMilliseconds -lt 1000) { "1"} else {[int]($lastExecutionTimeSpan.Seconds + ($lastExecutionTimeSpan.Milliseconds / 1000))}) | |
[...] | |
Write-Host $curPath -ForegroundColor Green -NoNewline | |
Write-Host " • took " -ForegroundColor White -NoNewline | |
Write-Host "$lastExecutionTime" -ForegroundColor Yellow | |
[...] | |
"$('>' * ($nestedPromptLevel + 1)) " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment