@@ -656,45 +656,34 @@ end
656656# ==============================
657657
658658function __bobthefish_prompt_aws_profile -S -d ' Show AWS profile'
659- [ " $theme_display_aws_profile " = ' yes' ]
659+ [ " $theme_display_aws_profile " = ' yes' -o " $theme_display_aws_vault_profile " = ' yes ' ]
660660 or return
661661
662- [ -n " $AWS_PROFILE " ]
663- or return
664-
665- set -l profile $AWS_PROFILE
666- set -l segment $profile
667-
668- __bobthefish_start_segment $color_aws
669- echo -ns $segment ' '
670- end
671-
672- function __bobthefish_prompt_aws_vault_profile -S -d ' Show AWS Vault profile'
673- [ " $theme_display_aws_vault_profile " = ' yes' ]
674- or return
675-
676- [ -n " $AWS_VAULT " -a -n " $AWS_SESSION_EXPIRATION " ]
677- or return
662+ if set -q " AWS_PROFILE"
663+ __bobthefish_start_segment $color_aws
664+ echo -ns $AWS_PROFILE ' '
665+ end
678666
679- set -l profile $AWS_VAULT
667+ if set -q " AWS_VAULT"
668+ set -l now (date --utc +%s)
669+ set -l expiry (date -d " $AWS_SESSION_EXPIRATION " +%s)
670+ set -l diff_mins (math " floor(( $expiry - $now ) / 60)" )
680671
681- set -l now (date --utc +%s)
682- set -l expiry (date -d " $AWS_SESSION_EXPIRATION " +%s)
683- set -l diff_mins (math " floor(( $expiry - $now ) / 60)" )
672+ set -l diff_time $diff_mins " m"
673+ [ $diff_mins -le 0 ]
674+ and set -l diff_time ' 0m'
675+ [ $diff_mins -ge 60 ]
676+ and set -l diff_time (math " floor($diff_mins / 60)" )" h" (math " $diff_mins % 60" )" m"
684677
685- set -l diff_time $diff_mins " m"
686- [ $diff_mins -le 0 ]
687- and set -l diff_time ' 0m'
688- [ $diff_mins -ge 60 ]
689- and set -l diff_time (math " floor($diff_mins / 60)" )" h" (math " $diff_mins % 60" )" m"
678+ set -l segment $profile ' (' $diff_time ' )'
679+ set -l status_color $color_aws
680+ [ $diff_mins -le 0 ]
681+ and set -l status_color $color_aws_vault_expired
690682
691- set -l segment $profile ' (' $diff_time ' )'
692- set -l status_color $color_aws
693- [ $diff_mins -le 0 ]
694- and set -l status_color $color_aws_vault_expired
695683
696- __bobthefish_start_segment $status _color
697- echo -ns $segment ' '
684+ __bobthefish_start_segment $color_aws
685+ echo -ns $AWS_VAULT ' '
686+ end
698687end
699688
700689
@@ -1149,7 +1138,6 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
11491138
11501139 # Cloud Tools
11511140 __bobthefish_prompt_aws_profile
1152- __bobthefish_prompt_aws_vault_profile
11531141
11541142 # Virtual environments
11551143 __bobthefish_prompt_nix
0 commit comments