Skip to content

Commit 21f01d6

Browse files
tradiffJanDeDobbeleer
authored andcommitted
feat: execution time for powershell 5
1 parent 85b1fc2 commit 21f01d6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/docs/installation.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ Edit `$PROFILE` in your preferred PowerShell version and add the following lines
234234
235235
$executionTime = -1
236236
$history = Get-History -ErrorAction Ignore -Count 1
237-
if ($null -ne $history -and $null -ne $history.Duration) {
238-
$executionTime = $history.Duration.TotalMilliseconds
237+
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime) {
238+
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
239239
}
240240
241241
$startInfo = New-Object System.Diagnostics.ProcessStartInfo

packages/powershell/oh-my-posh/oh-my-posh.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ function Set-PoshPrompt {
7474

7575
$executionTime = -1
7676
$history = Get-History -ErrorAction Ignore -Count 1
77-
if ($null -ne $history -and $null -ne $history.Duration) {
78-
$executionTime = $history.Duration.TotalMilliseconds
77+
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime) {
78+
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
7979
}
8080

8181
$startInfo = New-Object System.Diagnostics.ProcessStartInfo

0 commit comments

Comments
 (0)