Seems you have a typo in your duration calculation, for days you have 68400 instead of 86400.
Also noticed you are moding multiple times, you can just do the final mod.
Finally you can use fish's math built in instead of expr
set -l cmd_duration (math -s0 $CMD_DURATION / 1000)
set seconds (math -s0 $cmd_duration % 60)'s'
if [ $cmd_duration -ge 60 ]
set minutes (math -s0 $cmd_duration % 3600 / 60)'m'
if [ $cmd_duration -ge 3600 ]
set hours (math -s0 $cmd_duration % 86400 / 3600)'h'
if [ $cmd_duration -ge 86400 ]
set days (math -s0 $cmd_duration / 86400)'d'
end
end
end
Seems you have a typo in your duration calculation, for days you have
68400
instead of86400
. Also noticed you aremod
ing multiple times, you can just do the finalmod
. Finally you can use fish'smath
built in instead ofexpr