# HG changeset patch # User Augie Fackler # Date 1457655143 18000 # Node ID 491cd0cedeeef01c7dde3e83939462b4ff21e493 # Parent e84b6da69ea09b50d8a5cbb4c4232d861baa3a4d prompt: use async.zsh to avoid weird disowned process jank 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 @@ -21,21 +21,18 @@ preexec () { PROMPT_TMP="${HOME}/.augie-zsh-tmp-prompt" function right_side_prompt() { + cd $1 branch=`vcs_current_branch` if [ $? = 0 ] ; then - echo -n $branch > "$PROMPT_TMP" - kill -s USR1 $$ + print $branch fi } -function TRAPUSR1() { - rps_branch=$(cat "$PROMPT_TMP") - zle && zle reset-prompt -} - -function precmd () { - rps_branch="$(date '+%D %H:%M')" - right_side_prompt &! +function right_prompt_results() { + if [ $2 = 0 ] ; then + rps_branch=$3 + zle && zle reset-prompt + fi } if [ "x`whoami`" = "xroot" ] ; then @@ -72,8 +69,16 @@ if [[ $TERM == "dumb" ]]; then # in ema unsetopt zle unsetopt prompt_cr unsetopt prompt_subst - unfunction precmd unfunction preexec +else + autoload -Uz async && async + async_start_worker durin42_prompt -u -n + async_register_callback durin42_prompt right_prompt_results + + function precmd () { + rps_branch="$(date '+%D %H:%M')" + async_job durin42_prompt right_side_prompt $PWD + } fi