From 21f01d69e8fc885e3957554491ab01d108fb7de9 Mon Sep 17 00:00:00 2001 From: TravisTX Date: Sat, 19 Dec 2020 06:03:51 -0700 Subject: [PATCH] feat: execution time for powershell 5 --- docs/docs/installation.mdx | 4 ++-- packages/powershell/oh-my-posh/oh-my-posh.psm1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/installation.mdx b/docs/docs/installation.mdx index d314111d..17a0b0a2 100644 --- a/docs/docs/installation.mdx +++ b/docs/docs/installation.mdx @@ -234,8 +234,8 @@ Edit `$PROFILE` in your preferred PowerShell version and add the following lines $executionTime = -1 $history = Get-History -ErrorAction Ignore -Count 1 - if ($null -ne $history -and $null -ne $history.Duration) { - $executionTime = $history.Duration.TotalMilliseconds + if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime) { + $executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds } $startInfo = New-Object System.Diagnostics.ProcessStartInfo diff --git a/packages/powershell/oh-my-posh/oh-my-posh.psm1 b/packages/powershell/oh-my-posh/oh-my-posh.psm1 index 090f13b8..0a2930fd 100644 --- a/packages/powershell/oh-my-posh/oh-my-posh.psm1 +++ b/packages/powershell/oh-my-posh/oh-my-posh.psm1 @@ -74,8 +74,8 @@ function Set-PoshPrompt { $executionTime = -1 $history = Get-History -ErrorAction Ignore -Count 1 - if ($null -ne $history -and $null -ne $history.Duration) { - $executionTime = $history.Duration.TotalMilliseconds + if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime) { + $executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds } $startInfo = New-Object System.Diagnostics.ProcessStartInfo