diff .shell.d/99.prompt.zsh @ 380:0ceb8554801e

zsh: make vcs info in prompt async Roughly cribbed from [0], but I'm hoping to rework this soon to use the zsh async library that shouldn't require a tempfile. 0: http://www.anishathalye.com/2015/02/07/an-asynchronous-shell-prompt/
author Augie Fackler <raf@durin42.com>
date Thu, 10 Mar 2016 18:56:28 -0500
parents 02b635053e8f
children 491cd0cedeee
line wrap: on
line diff
--- a/.shell.d/99.prompt.zsh
+++ b/.shell.d/99.prompt.zsh
@@ -18,17 +18,24 @@ preexec () {
         fi
 }
 
+PROMPT_TMP="${HOME}/.augie-zsh-tmp-prompt"
+
 function right_side_prompt() {
     branch=`vcs_current_branch`
     if [ $? = 0 ] ; then
-        echo -n $branch
-    else
-        date '+%D %H:%M'
+        echo -n $branch > "$PROMPT_TMP"
+        kill -s USR1 $$
     fi
 }
 
+function TRAPUSR1() {
+    rps_branch=$(cat "$PROMPT_TMP")
+    zle && zle reset-prompt
+}
+
 function precmd () {
-    rps_branch=`right_side_prompt`
+    rps_branch="$(date '+%D %H:%M')"
+    right_side_prompt &!
 }
 
 if [ "x`whoami`" = "xroot" ] ; then