Skip to content

Commit a0c9d86

Browse files
committed
add Get-HistoryEntryDuration
1 parent 9f853b1 commit a0c9d86

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Format-ShortInterval.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Function Format-ShortInterval([Parameter(Mandatory)] [TimeSpan] $Interval) {
99
#>
1010

1111
if ($Interval.TotalMinutes -lt 1.0) {
12-
return "{0:f2}s" -f $Interval.TotalSeconds
12+
return "{0:f1}s" -f $Interval.TotalSeconds
1313
}
1414

1515
if ($Interval.TotalHours -lt 1.0) {

PrettyPrompt.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
. "$PSScriptRoot\Format-ShortInterval.ps1"
22
. "$PSScriptRoot\Is-Administrator.ps1"
3+
. "$PSScriptRoot\Utils.ps1"
34

45
Function PrettyPrompt([System.ConsoleColor] $UserColor = "Blue", [System.ConsoleColor] $AdminColor = "Red", [System.ConsoleColor] $HostColor = "White") {
56
<#
@@ -33,8 +34,7 @@ Function PrettyPrompt([System.ConsoleColor] $UserColor = "Blue", [System.Console
3334
return [TimeSpan]0
3435
}
3536

36-
$LastCmd = (Get-History)[-1]
37-
return $LastCmd.EndExecutionTime - $LastCmd.StartExecutionTime
37+
return Get-HistoryEntryDuration((Get-History)[-1])
3838
}
3939

4040
function Get-ShortLocation {

Utils.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Function Get-HistoryEntryDuration([Microsoft.PowerShell.Commands.HistoryInfo] $HistoryEntry) {
2+
return $HistoryEntry.EndExecutionTime - $HistoryEntry.StartExecutionTime
3+
}
4+
15
Function Search-Google {
26
<#
37
.SYNOPSIS

0 commit comments

Comments
 (0)