mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
show current AWS Profile in prompt
This commit is contained in:
parent
c2c47dc964
commit
171fa56ec8
@ -684,6 +684,33 @@ function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS Vault profile'
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# ==============================
|
||||
# User / hostname info segments
|
||||
@ -1169,6 +1196,7 @@ 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