diff options
Diffstat (limited to '.config/fisher/github.com/matchai/spacefish/functions/__sf_util_human_time.fish')
-rw-r--r-- | .config/fisher/github.com/matchai/spacefish/functions/__sf_util_human_time.fish | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/.config/fisher/github.com/matchai/spacefish/functions/__sf_util_human_time.fish b/.config/fisher/github.com/matchai/spacefish/functions/__sf_util_human_time.fish new file mode 100644 index 00000000..ce804749 --- /dev/null +++ b/.config/fisher/github.com/matchai/spacefish/functions/__sf_util_human_time.fish @@ -0,0 +1,23 @@ +# +# Human time +# + +function __sf_util_human_time -d "Humanize a time interval for display" + command awk ' + function hmTime(time, stamp) { + split("h:m:s:ms", units, ":") + for (i = 2; i >= -1; i--) { + if (t = int( i < 0 ? time % 1000 : time / (60 ^ i * 1000) % 60 )) { + stamp = stamp t units[sqrt((i - 2) ^ 2) + 1] " " + } + } + if (stamp ~ /^ *$/) { + return "0ms" + } + return substr(stamp, 1, length(stamp) - 1) + } + { + print hmTime($0) + } + ' +end |