fix(git): turn off async prompt by default on zsh < 5.0.6 (#12331)
See https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index c4265970bb9756393642618485df49c62d6115d2..277c0b3e891fd4467550a9b51d4d8e31705614e2 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -1,3 +1,5 @@
6+autoload -Uz is-at-least
7+
8 # The git prompt's git commands are read-only and should not interfere with
9 # other processes. This environment variable is equivalent to running with `git
10 # --no-optional-locks`, but falls back gracefully for older versions of git.
11@@ -37,8 +39,10 @@ function _omz_git_prompt_info() {
12 echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
13 }
1415-# Enable async prompt by default unless the setting is at false / no
16-if zstyle -T ':omz:alpha:lib:git' async-prompt; then
17+# Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6
18+# https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268
19+if zstyle -t ':omz:alpha:lib:git' async-prompt \
20+ || { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
21 function git_prompt_info() {
22 setopt localoptions noksharrays
23 if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then