Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'vaulted' shells #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions agnoster.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,42 @@ prompt_virtualenv() {
fi
}

epoch_date() {
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
echo $(date -d $1 +%s)
elif [[ "$unamestr" == 'Darwin' ]]; then
echo $(date -j -f %Y-%m-%dT%H:%M:%S%z $1 +%s)
else # TODO - other platforms?
echo $(date -j -f %Y-%m-%dT%H:%M:%S%z $1 +%s)
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=$(epoch_date $exp)
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
}

## Main prompt
prompt_agnoster_main() {
RETVAL=$?
CURRENT_BG='NONE'
prompt_status
prompt_context
prompt_virtualenv
prompt_vaulted
prompt_dir
prompt_git
prompt_end
Expand Down