Browse Source

Revert fbcda4d

The PROMPT building method clashes with other themes and
plugins that modify the PROMPT variable.

Also reverted the $jobstates trick due to it not working
inside $PROMPT.
master^2
Marc Cornellà 2 years ago
parent
commit
8f3737f45b
1 changed files with 19 additions and 23 deletions
  1. +19
    -23
      themes/agnoster.zsh-theme

+ 19
- 23
themes/agnoster.zsh-theme View File

@@ -29,7 +29,6 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts

CURRENT_BG='NONE'
zmodload zsh/parameter

# Special Powerline characters

@@ -56,23 +55,23 @@ prompt_segment() {
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
PROMPT+=" %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
else
PROMPT+="%{$bg%}%{$fg%} "
echo -n "%{$bg%}%{$fg%} "
fi
CURRENT_BG=$1
[[ -n $3 ]] && PROMPT+=$3
[[ -n $3 ]] && echo -n $3
}

# End the prompt, closing any open segments
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
PROMPT+=" %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else
PROMPT+="%{%k%}"
echo -n "%{%k%}"
fi
PROMPT+="%{%f%}"
CURRENT_BG='NONE'
echo -n "%{%f%}"
CURRENT_BG=''
}

### Prompt components
@@ -124,7 +123,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
PROMPT+="${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi
}

@@ -136,15 +135,15 @@ prompt_bzr() {
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black
PROMPT+="bzr@$revision ✚ "
echo -n "bzr@"$revision "✚ "
else
if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black
PROMPT+="bzr@$revision"
echo -n "bzr@"$revision

else
prompt_segment green black
PROMPT+="bzr@$revision"
echo -n "bzr@"$revision
fi
fi
fi
@@ -158,30 +157,30 @@ prompt_hg() {
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st=' ±'
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_segment yellow black
st=' ±'
st='±'
else
# if working copy is clean
prompt_segment green black
fi
PROMPT+="$(hg prompt "☿ {rev}@{branch}")$st"
echo -n $(hg prompt "☿ {rev}@{branch}") $st
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
prompt_segment red black
st=' ±'
st='±'
elif `hg st | grep -q "^[MA]"`; then
prompt_segment yellow black
st=' ±'
st='±'
else
prompt_segment green black
fi
PROMPT+="☿ $rev@$branch$st"
echo -n "☿ $rev@$branch" $st
fi
fi
}
@@ -208,7 +207,7 @@ prompt_status() {
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
[[ ${#jobstates} -ne 0 ]] && symbols+="%{%F{cyan}%}⚙"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"

[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
}
@@ -216,7 +215,6 @@ prompt_status() {
## Main prompt
build_prompt() {
RETVAL=$?
PROMPT='%{%f%b%k%}'
prompt_status
prompt_virtualenv
prompt_context
@@ -225,8 +223,6 @@ build_prompt() {
prompt_bzr
prompt_hg
prompt_end
PROMPT+=' '
}

autoload -U add-zsh-hook
add-zsh-hook precmd build_prompt
PROMPT='%{%f%b%k%}$(build_prompt) '

Loading…
Cancel
Save