Mercurial > dotfiles
comparison .shell.d/99.prompt.zsh @ 514:7e8603e0a822
zsh: properly set up zsh async stuff
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Thu, 03 Jun 2021 14:26:57 -0400 |
| parents | 2dd040318107 |
| children | e69d3e15b1b7 |
comparison
equal
deleted
inserted
replaced
| 513:ad9ca178e094 | 514:7e8603e0a822 |
|---|---|
| 26 if [ $? = 0 ] ; then | 26 if [ $? = 0 ] ; then |
| 27 print $branch | 27 print $branch |
| 28 fi | 28 fi |
| 29 } | 29 } |
| 30 | 30 |
| 31 function _init_async() { | |
| 32 async | |
| 33 async_stop_worker 'durin42_prompt' || true | |
| 34 async_start_worker durin42_prompt -u -n | |
| 35 async_register_callback durin42_prompt right_prompt_results | |
| 36 } | |
| 37 | |
| 31 function right_prompt_results() { | 38 function right_prompt_results() { |
| 32 if [ $2 = 0 ] ; then | 39 if [ $2 = 0 ] ; then |
| 33 rps_branch=$3 | 40 rps_branch=$3 |
| 34 zle && zle reset-prompt | 41 zle && zle reset-prompt |
| 42 else | |
| 43 _init_async | |
| 35 fi | 44 fi |
| 36 } | 45 } |
| 37 | 46 |
| 38 if [ "x`whoami`" = "xroot" ] ; then | 47 if [ "x`whoami`" = "xroot" ] ; then |
| 39 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' | 48 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' |
| 71 unsetopt prompt_subst | 80 unsetopt prompt_subst |
| 72 unfunction preexec | 81 unfunction preexec |
| 73 PS1='$ ' | 82 PS1='$ ' |
| 74 RPS1='' | 83 RPS1='' |
| 75 else | 84 else |
| 76 autoload -Uz async && async | 85 autoload -Uz async |
| 77 async_start_worker durin42_prompt -u -n | 86 _init_async |
| 78 async_register_callback durin42_prompt right_prompt_results | |
| 79 | |
| 80 function precmd () { | 87 function precmd () { |
| 81 rps_branch="$(date '+%D %H:%M')" | 88 rps_branch="$(date '+%D %H:%M')" |
| 82 async_job durin42_prompt right_side_prompt $PWD | 89 async_job durin42_prompt right_side_prompt $PWD |
| 83 } | 90 } |
| 84 fi | 91 fi |
