From d5f713e950281163a12ff3fa6e98bfc2c1cbb6d0 Mon Sep 17 00:00:00 2001 From: Tor Arvid Lund Date: Wed, 7 Jun 2017 17:44:58 +0200 Subject: [PATCH] Add support for 'vaulted' shells in agnoster theme If a user is currently in a [vaulted](github.com/miquella/vaulted) shell, they will now have an indication of this in the agnoster prompt, not unlike the virtualenv prompt. The foreground color will switch if the timer expires (which usually signifies that the temporary Amazon keys generated by vaulted will be invalid). --- themes/agnoster.zsh-theme | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 07546fd34..d97e2e487 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -198,6 +198,23 @@ prompt_virtualenv() { fi } +# vaulted: current vaulted shell +prompt_vaulted() { + if [[ -z $VAULTED_ENV ]]; then + return + fi + local exp=$(echo $VAULTED_ENV_EXPIRATION | sed 's/Z/+0000/') + local valid_until=$(date -j -f %Y-%m-%dT%H:%M:%S%z $exp +%s) + local bg=009 #orange + local fg=black + if [[ $valid_until -lt $(date +%s) ]]; then + fg=blue + fi + if [[ -n $VAULTED_ENV ]]; then + prompt_segment $bg $fg "$VAULTED_ENV" + fi +} + # Status: # - was there an error # - am I root @@ -217,6 +234,7 @@ build_prompt() { RETVAL=$? prompt_status prompt_virtualenv + prompt_vaulted prompt_context prompt_dir prompt_git