|
|
@ -32,9 +32,7 @@
|
|
|
|
# Load dependencies.
|
|
|
|
# Load dependencies.
|
|
|
|
pmodload 'helper'
|
|
|
|
pmodload 'helper'
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_sorin_async_callback {
|
|
|
|
function prompt_sorin_async_git_callback {
|
|
|
|
case $1 in
|
|
|
|
|
|
|
|
prompt_sorin_async_git)
|
|
|
|
|
|
|
|
# We can safely split on ':' because it isn't allowed in ref names.
|
|
|
|
# We can safely split on ':' because it isn't allowed in ref names.
|
|
|
|
IFS=':' read _git_target _git_post_target <<<"$3"
|
|
|
|
IFS=':' read _git_target _git_post_target <<<"$3"
|
|
|
|
|
|
|
|
|
|
|
@ -53,8 +51,6 @@ function prompt_sorin_async_callback {
|
|
|
|
_prompt_sorin_git="${_git_target}${_git_post_target}"
|
|
|
|
_prompt_sorin_git="${_git_target}${_git_post_target}"
|
|
|
|
zle && zle reset-prompt
|
|
|
|
zle && zle reset-prompt
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_sorin_async_git {
|
|
|
|
function prompt_sorin_async_git {
|
|
|
@ -66,19 +62,21 @@ function prompt_sorin_async_git {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_sorin_async_tasks {
|
|
|
|
function prompt_sorin_async_tasks {
|
|
|
|
# Initialize async worker. This needs to be done here and not in
|
|
|
|
# If we've got a pending request, cancel it
|
|
|
|
# prompt_sorin_setup so the git formatting can be overridden by other prompts.
|
|
|
|
if [[ -n "$_prompt_sorin_async_fd" ]] && { true <&$_prompt_sorin_async_fd } 2>/dev/null; then
|
|
|
|
if (( !${prompt_prezto_async_init:-0} )); then
|
|
|
|
# Close the file descriptor and remove the handler
|
|
|
|
async_start_worker prompt_sorin -n
|
|
|
|
exec {_prompt_sorin_async_fd}<&-
|
|
|
|
async_register_callback prompt_sorin prompt_sorin_async_callback
|
|
|
|
zle -F $_prompt_sorin_async_fd
|
|
|
|
typeset -g prompt_prezto_async_init=1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Kill the old process of slow commands if it is still running.
|
|
|
|
# Fork a process to fetch the git info and open a pipe to read from it
|
|
|
|
async_flush_jobs prompt_sorin
|
|
|
|
exec {_prompt_sorin_async_fd}< <(
|
|
|
|
|
|
|
|
# Fetch and print the suggestion
|
|
|
|
|
|
|
|
prompt_sorin_async_git "$PWD"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Compute slow commands in the background.
|
|
|
|
# When the fd is readable, call the response handler
|
|
|
|
async_job prompt_sorin prompt_sorin_async_git "$PWD"
|
|
|
|
zle -F "$_prompt_sorin_async_fd" prompt_sorin_async_callback
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_sorin_precmd {
|
|
|
|
function prompt_sorin_precmd {
|
|
|
@ -113,7 +111,6 @@ function prompt_sorin_setup {
|
|
|
|
|
|
|
|
|
|
|
|
# Load required functions.
|
|
|
|
# Load required functions.
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
autoload -Uz async && async
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add hook for calling git-info before each command.
|
|
|
|
# Add hook for calling git-info before each command.
|
|
|
|
add-zsh-hook precmd prompt_sorin_precmd
|
|
|
|
add-zsh-hook precmd prompt_sorin_precmd
|
|
|
|