Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Last active June 13, 2018 15:35
Show Gist options
  • Save jtimberman/fbc7843d75c04deede546474af992515 to your computer and use it in GitHub Desktop.
Save jtimberman/fbc7843d75c04deede546474af992515 to your computer and use it in GitHub Desktop.
jtimberman.zsh-theme - but with -theme it doesn't syntax highlight....
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%} %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%} %{$fg[green]%}✔%{$reset_color%}"
function chef_profile_prompt() {
[[ -n $CHEF_PROFILE ]] && echo " %{%F{blue}%}${CHEF_PROFILE}%{$reset_color%}"
}
function aws_profile_prompt() {
[[ -n $AWS_PROFILE ]] && echo " %{%F{yellow}%}${AWS_PROFILE}%{$reset_color%}$(okta_session_prompt)"
}
function okta_session_prompt() {
if [ -f ~/.okta_session_time ]; then
local time_since=`expr $(date +%s) - $(cat ~/.okta_session_time)`
if [ $time_since -gt 3600 ]; then
echo ":%{%F{red}EXPIRED%{$reset_color%}"
fi
fi
}
setopt prompt_subst
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
RPS1="${return_code}"
PROMPT='| %(?,%{%F{green}%},%{%F{red}%})%m:%{%{$reset_color%}%}%~$(chef_profile_prompt)$(aws_profile_prompt)
%{$reset_color%}| $(git_prompt_info)%#%{$reset_color%} '
# e.g.:
#
# use_aws chef-utility
#
function use_aws() {
export AWS_PROFILE=$1
okta_aws $AWS_PROFILE
okta_session
}
function okta_session() {
date +%s > ~/.okta_session_time
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment