mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2025-12-06 07:20:40 +01:00
feat(git): add escape hatch to enable async prompt
This commit is contained in:
16
lib/git.zsh
16
lib/git.zsh
@@ -44,6 +44,7 @@ function _omz_git_prompt_info() {
|
||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12331
|
||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12360
|
||||
# TODO(2024-06-12): @mcornella remove workaround when CentOS 7 reaches EOL
|
||||
local _style
|
||||
if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
||||
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
|
||||
function git_prompt_info() {
|
||||
@@ -81,6 +82,21 @@ if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
||||
# Register the async handler first. This needs to be done before
|
||||
# the async request prompt is run
|
||||
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||
elif zstyle -s ':omz:alpha:lib:git' async-prompt _style && [[ $_style == "force" ]]; then
|
||||
function git_prompt_info() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_prompt_status() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||
fi
|
||||
}
|
||||
|
||||
_omz_register_handler _omz_git_prompt_info
|
||||
_omz_register_handler _omz_git_prompt_status
|
||||
else
|
||||
function git_prompt_info() {
|
||||
_omz_git_prompt_info
|
||||
|
||||
Reference in New Issue
Block a user