# HG changeset patch # User Augie Fackler # Date 1457654188 18000 # Node ID 0ceb8554801eba7db799fd89d044cd16b8e67bcd # Parent 0b8457903012e0311ad0c35c9cb7b266906d80d7 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/ diff --git a/.shell.d/99.prompt.zsh b/.shell.d/99.prompt.zsh --- 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