merge aws_profile functions and let AWS_VAULT take precedence

pull/349/merge^2
Sebastian Noe 7 months ago
parent fa8e05dbfb
commit fa33f4311a

@ -657,42 +657,16 @@ end
# Cloud Tools
# ==============================
function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS Vault profile'
[ "$theme_display_aws_vault_profile" = 'yes' ]
function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS \(Vault\) profile'
[ "$theme_display_aws_vault_profile" = 'yes' -o "$theme_display_aws_profile" = 'yes' ]
or return
[ -n "$AWS_VAULT" -a -n "$AWS_SESSION_EXPIRATION" ]
[ -n "$AWS_SESSION_EXPIRATION" -a \( -n "$AWS_VAULT" -o -n "$AWS_PROFILE" \) ]
or return
set -l profile $AWS_VAULT
set -l now (date --utc +%s)
set -l expiry (date -d "$AWS_SESSION_EXPIRATION" +%s)
set -l diff_mins (math "floor(( $expiry - $now ) / 60)")
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 ')'
set -l status_color $color_aws_vault
[ $diff_mins -le 0 ]
and set -l status_color $color_aws_vault_expired
__bobthefish_start_segment $status_color
echo -ns $segment ' '
end
function __bobthefish_prompt_aws_profile -S -d 'Show current AWS profile'
[ "$theme_display_aws_profile" = 'yes' ]
or return
[ -n "$AWS_PROFILE" -a -n "$AWS_SESSION_EXPIRATION" ]
or return
set -l profile $AWS_PROFILE
[ -n "$AWS_VAULT" ]
and set -l profile $AWS_VAULT
or set -l profile $AWS_PROFILE
set -l now (date --utc +%s)
set -l expiry (date -d "$AWS_SESSION_EXPIRATION" +%s)
@ -1197,7 +1171,6 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
# Cloud Tools
__bobthefish_prompt_aws_vault_profile
__bobthefish_prompt_aws_profile
# Virtual environments
__bobthefish_prompt_nix

Loading…
Cancel
Save