changeset 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 ad9ca178e094
children 62e62b885540
files .shell.d/99.prompt.zsh
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.shell.d/99.prompt.zsh
+++ b/.shell.d/99.prompt.zsh
@@ -28,10 +28,19 @@ function right_side_prompt() {
     fi
 }
 
+function _init_async() {
+    async
+    async_stop_worker 'durin42_prompt' || true
+    async_start_worker durin42_prompt -u -n
+    async_register_callback durin42_prompt right_prompt_results
+}
+
 function right_prompt_results() {
     if [ $2 = 0 ] ; then
         rps_branch=$3
         zle && zle reset-prompt
+     else
+         _init_async
      fi
 }
 
@@ -73,10 +82,8 @@ if [[ $TERM == "dumb" ]]; then  # in ema
     PS1='$ '
     RPS1=''
 else
-    autoload -Uz async && async
-    async_start_worker durin42_prompt -u -n
-    async_register_callback durin42_prompt right_prompt_results
-
+    autoload -Uz async
+    _init_async
     function precmd () {
         rps_branch="$(date '+%D %H:%M')"
         async_job durin42_prompt right_side_prompt $PWD