Mercurial > dotfiles
diff .shell.d/99.prompt.zsh @ 382:491cd0cedeee
prompt: use async.zsh to avoid weird disowned process jank
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Thu, 10 Mar 2016 19:12:23 -0500 |
parents | 0ceb8554801e |
children | 2dd040318107 |
line wrap: on
line diff
--- 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