fix: fish 3.2 empty command duration

This commit is contained in:
lnu 2021-03-19 22:22:37 +01:00 committed by Jan De Dobbeleer
parent 838567cbcd
commit 494d3b2d20

View file

@ -1,11 +1,22 @@
function fish_prompt
set -l omp_duration "$CMD_DURATION$cmd_duration"
if test "$omp_lastcommand" = ""
set omp_duration 0
# check if variable set, < 3.2 case
if set -q omp_lastcommand; and test "$omp_lastcommand" = ""
set omp_duration 0
end
# works with fish >=3.2
if set -q omp_last_status_generation; and test "$omp_last_status_generation" = "$status_generation"
set omp_duration 0
end
if set -q status_generation
set -gx omp_last_status_generation $status_generation
end
::OMP:: --config ::CONFIG:: --error $status --execution-time $omp_duration
end
function postexec_omp --on-event fish_postexec
# works with fish <3.2
# pre and postexec not fired for empty command in fish >=3.2
set -gx omp_lastcommand $argv
end