Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sindresorhus/pure
Browse files Browse the repository at this point in the history
  • Loading branch information
chabou committed Jan 27, 2019
2 parents f4ef240 + d5e14a3 commit 775c80b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
35 changes: 31 additions & 4 deletions async.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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##*:*:}%\=*})

Expand All @@ -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)
Expand Down Expand Up @@ -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 &
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 11 additions & 0 deletions pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 775c80b

Please sign in to comment.