Create new segment for AWS Vault profile

* Tracks the session expiration information and adds this to
  the segment as well (if available - which it should be).
* Using basic blue/white colours at the moment.
* Added doco including link to AWS Vault repo.
pull/278/head
Darren Kidd 4 years ago committed by Justin Hileman
parent 140441fe36
commit bc94c77cbd

@ -124,6 +124,7 @@ set -g theme_newline_prompt '$ '
- `theme_display_vi`. By default the vi mode indicator will be shown if vi or hybrid key bindings are enabled. Use `no` to hide the indicator, or `yes` to show the indicator.
- `theme_display_k8s_context`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`).
- `theme_display_k8s_namespace`. This feature is disabled by default. Use `yes` to show the current kubernetes namespace.
- `theme_display_aws_vault_profile`. This feature is disabled by default. Use `yes` to show the currently executing [AWS Vault](https://github.com/99designs/aws-vault) profile.
- `theme_display_user`. If set to `yes`, display username always, if set to `ssh`, only when an SSH-Session is detected, if set to no, never.
- `theme_display_hostname`. Same behaviour as `theme_display_user`.
- `theme_display_sudo_user`. If set to `yes`, displays the sudo-username in a root shell. For example, when calling `sudo -s` and having this option set to `yes`, the username of the user, who called `sudo -s`, will be displayed.

@ -29,6 +29,7 @@
# set -g theme_display_docker_machine no
# set -g theme_display_k8s_context yes
# set -g theme_display_k8s_namespace no
# set -g theme_display_aws_vault_profile yes
# set -g theme_display_hg yes
# set -g theme_display_virtualenv no
# set -g theme_display_nix no
@ -644,6 +645,32 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
end
# ==============================
# Cloud Tools
# ==============================
function __bobthefish_prompt_aws_vault_profile -S -d 'Show AWS Vault profile'
[ "$theme_display_aws_vault_profile" = 'yes' ]
or return
[ -n "$AWS_VAULT" -a -n "$AWS_SESSION_EXPIRATION" ]
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)")
[ "$diff_mins" -lt 0 ]
and set -l diff_mins 0
set -l segment $profile " (" $diff_mins "m)"
__bobthefish_start_segment blue white --bold
echo -ns $segment " "
end
# ==============================
# User / hostname info segments
# ==============================
@ -1076,6 +1103,9 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_prompt_docker
__bobthefish_prompt_k8s_context
# Cloud Tools
__bobthefish_prompt_aws_vault_profile
# Virtual environments
__bobthefish_prompt_nix
__bobthefish_prompt_desk

Loading…
Cancel
Save