diff --git a/async.zsh b/async.zsh index d35f1287..fb273b13 100644 --- a/async.zsh +++ b/async.zsh @@ -3,12 +3,12 @@ # # zsh-async # -# version: 1.7.0 +# version: 1.7.1 # author: Mathias Fredriksson # url: https://github.com/mafredri/zsh-async # -typeset -g ASYNC_VERSION=1.7.0 +typeset -g ASYNC_VERSION=1.7.1 # Produce debug output from zsh-async when set to 1. typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0} @@ -92,7 +92,7 @@ _async_worker() { unset $zsh_hook_functions # And hooks with registered functions. unset zsh_hooks zsh_hook_functions # Cleanup. - child_exit() { + close_idle_coproc() { local -a pids pids=(${${(v)jobstates##*:*:}%\=*}) @@ -102,6 +102,10 @@ _async_worker() { coproc : coproc_pid=0 fi + } + + child_exit() { + close_idle_coproc # On older version of zsh (pre 5.2) we notify the parent through a # SIGWINCH signal because `zpty` did not return a file descriptor (fd) @@ -197,7 +201,6 @@ _async_worker() { if (( do_eval )); then shift cmd # Strip _async_eval from cmd. _async_eval $cmd - do_eval=0 else # Run job in background, completed jobs are printed to stdout. _async_job $cmd & @@ -206,6 +209,14 @@ _async_worker() { fi processing=0 # Disable guard. + + if (( do_eval )); then + do_eval=0 + + # When there are no active jobs we can't rely on the CHLD trap to + # manage the coproc lifetime. + close_idle_coproc + fi done } @@ -295,6 +306,22 @@ _async_zle_watcher() { local worker=$ASYNC_PTYS[$1] local callback=$ASYNC_CALLBACKS[$worker] + if [[ -n $2 ]]; then + # from man zshzle(1): + # `hup' for a disconnect, `nval' for a closed or otherwise + # invalid descriptor, or `err' for any other condition. + # Systems that support only the `select' system call always use + # `err'. + + # this has the side effect to unregister the broken file descriptor + async_stop_worker $worker + + if [[ -n $callback ]]; then + $callback '[async]' 2 "" 0 "$worker:zle -F $1 returned error $2" 0 + fi + return + fi; + if [[ -n $callback ]]; then async_process_results $worker $callback watcher fi diff --git a/package.json b/package.json index 55e667db..9416808e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pure-prompt-now", - "version": "1.8.0", + "version": "1.9.0-now.1", "description": "Pretty, minimal and fast ZSH prompt with Zeit's Now flavor", "license": "MIT", "repository": "chabou/pure-now", diff --git a/pure.zsh b/pure.zsh index 8296879f..e7ebf52e 100644 --- a/pure.zsh +++ b/pure.zsh @@ -183,6 +183,10 @@ prompt_pure_precmd() { # Check if we should display the virtual env, we use a sufficiently high # index of psvar (12) here to avoid collisions with user defined entries. psvar[12]= + # Check if a conda environment is active and display it's name + if [[ -n $CONDA_DEFAULT_ENV ]]; then + psvar[12]="${CONDA_DEFAULT_ENV//[$'\t\r\n']}" + fi # When VIRTUAL_ENV_DISABLE_PROMPT is empty, it was unset by the user and # Pure should take back control. if [[ -n $VIRTUAL_ENV ]] && [[ -z $VIRTUAL_ENV_DISABLE_PROMPT || $VIRTUAL_ENV_DISABLE_PROMPT = 12 ]]; then @@ -396,6 +400,13 @@ prompt_pure_async_callback() { local do_render=0 case $job in + \[async]) + # code is 1 for corrupted worker output and 2 for dead worker + if [[ $code -eq 2 ]]; then + # our worker died unexpectedly + typeset -g prompt_pure_async_init=0 + fi + ;; prompt_pure_async_vcs_info) local -A info typeset -gA prompt_pure_vcs_info