Update prompt setup

This commit is contained in:
J. Morgan Lieberthal 2021-04-18 01:55:23 -06:00
parent 97bad4280c
commit e8b8be4b2f
No known key found for this signature in database
GPG key ID: EFB7E99469668652

View file

@ -30,6 +30,8 @@ function prompt_jml_async_callback {
# The target actually contains 3 space separated possibilities, so we need to
# make sure we grab the first one.
_git_target=$(coalesce ${(@)${(z)_git_target}})
if [[ -z "$_git_target" ]]; then
# No git target detected, flush the git fragment and redisplay the prompt.
if [[ -n "$_prompt_jml_git" ]]; then
@ -42,6 +44,13 @@ function prompt_jml_async_callback {
zle && zle reset-prompt
fi
;;
"[async]" )
# Code is 1 for corrupted worker output and 2 for dead worker
if [[ $2 -eq 2 ]]; then
# Our worker died unexpectedly
typeset -g prompt_prezto_async_init=0
fi
;;
esac
}
@ -87,13 +96,19 @@ function prompt_jml_precmd {
fi
# Run python info (this should be fast and not require any async)
(( $+functions[python-info] )) && python-info
if (( $+functions[python-info] )); then
python-info
fi
# Run ruby info (this should be fast and not require any async)
(( $+functions[ruby-info] )) && ruby-info
if (( $+functions[ruby-info] )); then
ruby-info
fi
# Run node info (this should be fast and not require any async)
(( $+functions[node-info] )) && node-info
if (( $+functions[node-info] )); then
node-info
fi
_prompt_jml_devenv=''
@ -119,8 +134,8 @@ function prompt_jml_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
_prompt_jml_precmd_async_pid=0
_prompt_jml_precmd_async_data=$(mktemp "${TMPDIR:-/tmp}/jml-prompt-async-XXXXXXXXXX")
# _prompt_jml_precmd_async_pid=0
# _prompt_jml_precmd_async_data=$(mktemp "${TMPDIR:-/tmp}/jml-prompt-async-XXXXXXXXXX")
# Load required functions.
autoload -Uz add-zsh-hook
@ -129,6 +144,9 @@ function prompt_jml_setup {
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_jml_precmd
# Tell prezto we can manage this prompt
zstyle ':prezto:module:prompt' managed 'yes'
# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%B%F{7}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{13}%F{4}%F{6}%f%b'
@ -154,12 +172,6 @@ function prompt_jml_setup {
'status' '%b:%s%A%B%S%a%d%m%r%U%u'
# 'status' '%b %p %s%A%B%S%a%d%m%r%U%u'
# Set up non-zero return value display
local show_return="⚠ "
# Default is to show the return value
if zstyle -T ':prezto:module:prompt' show-return-val; then
show_return+='%? '
fi
# Set python-info format
zstyle ':prezto:module:python:info:virtualenv' format '%f@%F{3}%v%f'
zstyle ':prezto:module:python:info:version' format '%f%F{3}%v%F{7}'
@ -168,6 +180,13 @@ function prompt_jml_setup {
# Set node-info format
zstyle ':prezto:module:node:info:version' format '%F{2}%v%f'
# Set up non-zero return value display
local show_return="⚠ "
# Default is to show the return value
if zstyle -T ':prezto:module:prompt' show-return-val; then
show_return+='%? '
fi
# Get the async worker set up
_jml_cur_git_root=''
@ -184,7 +203,7 @@ function prompt_jml_setup {
PROMPT+='${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%(?:: %F{3}'
RPROMPT+=${show_return}
RPROMPT+='%f)${_prompt_jml_git}'
RPROMPT+='%f)${VIM:+" %B%F{6}V%f%b"}${_prompt_jml_git}'
SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? '
}