diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2018-06-09 13:05:26 -0400 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2018-06-09 13:05:26 -0400 |
commit | 59e91cd97fcc3c406751f019215f957b36614022 (patch) | |
tree | 850cab9426806618e7e8a7a7b5c905a2be019e50 /themes | |
parent | db38c7c3b2921783d955912262f87ee7dd8cd31b (diff) | |
parent | f461d21de1bd0c1394e57a2e3af69778692e4ba4 (diff) | |
download | zsh-59e91cd97fcc3c406751f019215f957b36614022.tar.gz zsh-59e91cd97fcc3c406751f019215f957b36614022.tar.bz2 zsh-59e91cd97fcc3c406751f019215f957b36614022.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'themes')
-rw-r--r--[-rwxr-xr-x] | themes/agnoster.zsh-theme | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 8da98ebcc..6ce248417 100755..100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -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" } @@ -225,7 +224,6 @@ prompt_cabal_sandbox() { ## Main prompt build_prompt() { RETVAL=$? - PROMPT='%{%f%b%k%}' prompt_status prompt_virtualenv prompt_context @@ -235,8 +233,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) ' |