From 5f7292092e1da50246487faaa451acef8b49b10c Mon Sep 17 00:00:00 2001 From: Darren Kidd <dev@kidd.life> Date: Wed, 9 Sep 2020 15:57:13 +1200 Subject: [PATCH] Anything greater than an hour now in XhYm format --- fish_prompt.fish | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 3dcdfb8..028185a 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -661,10 +661,14 @@ function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS Vault profile' set -l now (date --utc +%s) set -l expiry (date -d "$AWS_SESSION_EXPIRATION" +%s) set -l diff_mins (math "floor(( $expiry - $now ) / 60)") - [ "$diff_mins" -lt 0 ] - and set -l diff_mins 0 - set -l segment $profile " (" $diff_mins "m)" + set -l diff_time $diff_mins"m" + [ $diff_mins -le 0 ] + and set -l diff_time "0m" + [ $diff_mins -ge 60 ] + and set -l diff_time (math "floor($diff_mins / 60)")"h"(math "$diff_mins % 60")"m" + + set -l segment $profile " (" $diff_time ")" __bobthefish_start_segment $color_aws_vault echo -ns $segment " "