From 31fd9d8f85460c28cfa3f77dcfdcdef16f037d56 Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Wed, 6 May 2020 12:15:45 -0700 Subject: [PATCH] Add minutes and hours to cmd_duration --- functions/lean_load_right_prompt_items.fish | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/functions/lean_load_right_prompt_items.fish b/functions/lean_load_right_prompt_items.fish index b9dce7a..e237b0c 100644 --- a/functions/lean_load_right_prompt_items.fish +++ b/functions/lean_load_right_prompt_items.fish @@ -22,8 +22,23 @@ function _lean_status end function _lean_cmd_duration - if test (math $CMD_DURATION/1000) -gt $lean_cmd_duration_threshold - echo -n (math --scale=$lean_cmd_duration_decimals $CMD_DURATION/1000)'s' + set -l seconds (math --scale=$lean_cmd_duration_decimals $CMD_DURATION/1000) + + if test $seconds -gt $lean_cmd_duration_threshold + set -l secondsMod (math $seconds % 60) + + set -l minutes (math -s0 $seconds/60) + set -l minutesMod (math $minutes % 60) + + set -l hours (math -s0 $minutes/60) + + for time in hours minutesMod secondsMod + if test $$time -eq 0 + set -e $time + end + end + + echo {$hours}'h' {$minutesMod}'m' {$secondsMod}'s' end end