mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
merge aws_profile functions and let AWS_VAULT take precedence
This commit is contained in:
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…
Reference in New Issue
Block a user