File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function fish_right_prompt
13
13
else
14
14
set_color blue
15
15
end
16
- printf ' < %s ' (_convertsecs ( math $cmd_duration / 1000) )
16
+ printf ' (%s) ' (__print_duration $cmd_duration )
17
17
set_color 666666
18
18
printf ' < %s' (date +%H:%M:%S)
19
19
set_color normal
@@ -60,6 +60,23 @@ function _is_multiplexed
60
60
echo $multiplexer
61
61
end
62
62
63
- function _convertsecs
64
- printf " %02d:%02d:%02d\n" (math $argv [1] / 3600) (math (math $argv [1] \% 3600) / 60) (math $argv [1] \% 60)
63
+ function __print_duration
64
+ set duration $argv [1]
65
+
66
+ set -l millis (math $duration % 1000)
67
+ set -l seconds (math -s0 $duration / 1000 % 60)
68
+ set -l minutes (math -s0 $duration / 60000 % 60)
69
+ set -l hours (math -s0 $duration / 3600000 % 60)
70
+
71
+ if test $duration -lt 60000;
72
+ # Below a minute
73
+ printf " %d.%03ds\n" $seconds $millis
74
+ else if test $duration -lt 3600000;
75
+ # Below a hour
76
+ printf " %02d:%02d.%03d\n" $minutes $seconds $millis
77
+ else
78
+ # Everything else
79
+ printf " %02d:%02d:%02d.%03d\n" $hours $minutes $seconds $millis
80
+ end
65
81
end
82
+
You can’t perform that action at this time.
0 commit comments