diff options
Diffstat (limited to 'themes/agnoster.zsh-theme')
-rw-r--r-- | themes/agnoster.zsh-theme | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 07546fd34..518a14a37 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -13,9 +13,13 @@ # # In addition, I recommend the # [Solarized theme](https://github.com/altercation/solarized/) and, if you're -# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# using it on Mac OS X, [iTerm 2](https://iterm2.com/) over Terminal.app - # it has significantly better color fidelity. # +# If using with "light" variant of the Solarized color schema, set +# SOLARIZED_THEME variable to "light". If you don't specify, we'll assume +# you're using the "dark" variant. +# # # Goals # # The aim of this theme is to only show you *relevant* information. Like most @@ -30,6 +34,11 @@ CURRENT_BG='NONE' +case ${SOLARIZED_THEME:-dark} in + light) CURRENT_FG='white';; + *) CURRENT_FG='black';; +esac + # Special Powerline characters () { @@ -80,28 +89,31 @@ prompt_end() { # Context: user@hostname (who am I and where am I) prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then - prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" + prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m" fi } # Git: branch/detached head, dirty status prompt_git() { (( $+commands[git] )) || return + if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then + return + fi local PL_BRANCH_CHAR () { local LC_ALL="" LC_CTYPE="en_US.UTF-8" PL_BRANCH_CHAR=$'\ue0a0' # } local ref dirty mode repo_path - repo_path=$(git rev-parse --git-dir 2>/dev/null) if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + repo_path=$(git rev-parse --git-dir 2>/dev/null) dirty=$(parse_git_dirty) ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else - prompt_segment green black + prompt_segment green $CURRENT_FG fi if [[ -e "${repo_path}/BISECT_LOG" ]]; then @@ -140,7 +152,6 @@ prompt_bzr() { if [[ $status_all -gt 0 ]] ; then prompt_segment yellow black echo -n "bzr@"$revision - else prompt_segment green black echo -n "bzr@"$revision @@ -151,7 +162,7 @@ prompt_bzr() { prompt_hg() { (( $+commands[hg] )) || return - local rev status + local rev st branch if $(hg id >/dev/null 2>&1); then if $(hg prompt >/dev/null 2>&1); then if [[ $(hg prompt "{status|unknown}") = "?" ]]; then @@ -164,7 +175,7 @@ prompt_hg() { st='±' else # if working copy is clean - prompt_segment green black + prompt_segment green $CURRENT_FG fi echo -n $(hg prompt "☿ {rev}@{branch}") $st else @@ -178,7 +189,7 @@ prompt_hg() { prompt_segment yellow black st='±' else - prompt_segment green black + prompt_segment green $CURRENT_FG fi echo -n "☿ $rev@$branch" $st fi @@ -187,7 +198,7 @@ prompt_hg() { # Dir: current working directory prompt_dir() { - prompt_segment blue black '%~' + prompt_segment blue $CURRENT_FG '%~' } # Virtualenv: current working virtualenv @@ -203,8 +214,8 @@ prompt_virtualenv() { # - am I root # - are there background jobs? prompt_status() { - local symbols - symbols=() + local -a symbols + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" @@ -212,11 +223,25 @@ prompt_status() { [[ -n "$symbols" ]] && prompt_segment black default "$symbols" } +#AWS Profile: +# - display current AWS_PROFILE name +# - displays yellow on red if profile name contains 'production' or +# ends in '-prod' +# - displays black on green otherwise +prompt_aws() { + [[ -z "$AWS_PROFILE" ]] && return + case "$AWS_PROFILE" in + *-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;; + *) prompt_segment green black "AWS: $AWS_PROFILE" ;; + esac +} + ## Main prompt build_prompt() { RETVAL=$? prompt_status prompt_virtualenv + prompt_aws prompt_context prompt_dir prompt_git |