mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
feat: don't keep duration when no command is entered
pwsh and fish alignement
This commit is contained in:
parent
875214b8b7
commit
838567cbcd
|
@ -1,4 +1,11 @@
|
|||
function fish_prompt
|
||||
set -l omp_duration "$CMD_DURATION$cmd_duration"
|
||||
::OMP:: --config ::CONFIG:: --error $status --execution-time $omp_duration --shell fish
|
||||
if test "$omp_lastcommand" = ""
|
||||
set omp_duration 0
|
||||
end
|
||||
::OMP:: --config ::CONFIG:: --error $status --execution-time $omp_duration
|
||||
end
|
||||
|
||||
function postexec_omp --on-event fish_postexec
|
||||
set -gx omp_lastcommand $argv
|
||||
end
|
||||
|
|
|
@ -6,6 +6,9 @@ $global:PoshSettings = New-Object -TypeName PSObject -Property @{
|
|||
Theme = "";
|
||||
}
|
||||
|
||||
# used to detect empty hit
|
||||
$global:omp_lastHistoryId = -1
|
||||
|
||||
$config = "::CONFIG::"
|
||||
if (Test-Path $config) {
|
||||
$global:PoshSettings.Theme = (Resolve-Path -Path $config).Path
|
||||
|
@ -15,7 +18,7 @@ function global:Set-PoshContext {}
|
|||
|
||||
function global:Set-PoshGitStatus {
|
||||
if (Get-Module -Name "posh-git") {
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Justification='Variable used later(not in this scope)')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSProvideCommentHelp', '', Justification = 'Variable used later(not in this scope)')]
|
||||
$Global:GitStatus = Get-GitStatus
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +42,9 @@ function global:Set-PoshGitStatus {
|
|||
|
||||
$executionTime = -1
|
||||
$history = Get-History -ErrorAction Ignore -Count 1
|
||||
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime) {
|
||||
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
|
||||
if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime -and $global:omp_lastHistoryId -ne $history.Id) {
|
||||
$executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
|
||||
$global:omp_lastHistoryId = $history.Id
|
||||
}
|
||||
$omp = "::OMP::"
|
||||
$config = $global:PoshSettings.Theme
|
||||
|
|
Loading…
Reference in a new issue