Commit 8f3737f4 authored by Marc Cornellà's avatar Marc Cornellà
Browse files

Revert fbcda4d5

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.
parent 2642f0a8
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts # A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE' CURRENT_BG='NONE'
zmodload zsh/parameter
# Special Powerline characters # Special Powerline characters
...@@ -56,23 +55,23 @@ prompt_segment() { ...@@ -56,23 +55,23 @@ prompt_segment() {
[[ -n $1 ]] && bg="%K{$1}" || bg="%k" [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f" [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then 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 else
PROMPT+="%{$bg%}%{$fg%} " echo -n "%{$bg%}%{$fg%} "
fi fi
CURRENT_BG=$1 CURRENT_BG=$1
[[ -n $3 ]] && PROMPT+=$3 [[ -n $3 ]] && echo -n $3
} }
# End the prompt, closing any open segments # End the prompt, closing any open segments
prompt_end() { prompt_end() {
if [[ -n $CURRENT_BG ]]; then if [[ -n $CURRENT_BG ]]; then
PROMPT+=" %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else else
PROMPT+="%{%k%}" echo -n "%{%k%}"
fi fi
PROMPT+="%{%f%}" echo -n "%{%f%}"
CURRENT_BG='NONE' CURRENT_BG=''
} }
### Prompt components ### Prompt components
...@@ -124,7 +123,7 @@ prompt_git() { ...@@ -124,7 +123,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info 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 fi
} }
...@@ -136,15 +135,15 @@ prompt_bzr() { ...@@ -136,15 +135,15 @@ prompt_bzr() {
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
if [[ $status_mod -gt 0 ]] ; then if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black prompt_segment yellow black
PROMPT+="bzr@$revision ✚ " echo -n "bzr@"$revision "✚ "
else else
if [[ $status_all -gt 0 ]] ; then if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black prompt_segment yellow black
PROMPT+="bzr@$revision" echo -n "bzr@"$revision
else else
prompt_segment green black prompt_segment green black
PROMPT+="bzr@$revision" echo -n "bzr@"$revision
fi fi
fi fi
fi fi
...@@ -158,30 +157,30 @@ prompt_hg() { ...@@ -158,30 +157,30 @@ prompt_hg() {
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added # if files are not added
prompt_segment red white prompt_segment red white
st=' ±' st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification # if any modification
prompt_segment yellow black prompt_segment yellow black
st=' ±' st='±'
else else
# if working copy is clean # if working copy is clean
prompt_segment green black prompt_segment green black
fi fi
PROMPT+="$(hg prompt "☿ {rev}@{branch}")$st" echo -n $(hg prompt "☿ {rev}@{branch}") $st
else else
st="" st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null) branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then if `hg st | grep -q "^\?"`; then
prompt_segment red black prompt_segment red black
st=' ±' st='±'
elif `hg st | grep -q "^[MA]"`; then elif `hg st | grep -q "^[MA]"`; then
prompt_segment yellow black prompt_segment yellow black
st=' ±' st='±'
else else
prompt_segment green black prompt_segment green black
fi fi
PROMPT+="☿ $rev@$branch$st" echo -n "☿ $rev@$branch" $st
fi fi
fi fi
} }
...@@ -208,7 +207,7 @@ prompt_status() { ...@@ -208,7 +207,7 @@ prompt_status() {
symbols=() symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $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" [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
} }
...@@ -216,7 +215,6 @@ prompt_status() { ...@@ -216,7 +215,6 @@ prompt_status() {
## Main prompt ## Main prompt
build_prompt() { build_prompt() {
RETVAL=$? RETVAL=$?
PROMPT='%{%f%b%k%}'
prompt_status prompt_status
prompt_virtualenv prompt_virtualenv
prompt_context prompt_context
...@@ -225,8 +223,6 @@ build_prompt() { ...@@ -225,8 +223,6 @@ build_prompt() {
prompt_bzr prompt_bzr
prompt_hg prompt_hg
prompt_end prompt_end
PROMPT+=' '
} }
autoload -U add-zsh-hook PROMPT='%{%f%b%k%}$(build_prompt) '
add-zsh-hook precmd build_prompt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment