summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2024-04-17 20:21:18 +0200
committerMarc Cornellà <marc@mcornella.com>2024-04-17 20:21:18 +0200
commit1ed8d4b55530888bfa723e7dc6226a798260bdc8 (patch)
treec3e6d5d27277fea6bf385f43339ef3ac27668377
parent7ef3f49f97ff34db3785b1cea444eb4972b1937b (diff)
downloadzsh-1ed8d4b55530888bfa723e7dc6226a798260bdc8.tar.gz
zsh-1ed8d4b55530888bfa723e7dc6226a798260bdc8.tar.bz2
zsh-1ed8d4b55530888bfa723e7dc6226a798260bdc8.zip
fix(git): turn off async prompt by default on zsh < 5.0.6 (#12331)
See https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268
-rw-r--r--lib/git.zsh8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/git.zsh b/lib/git.zsh
index c4265970b..277c0b3e8 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -1,3 +1,5 @@
+autoload -Uz is-at-least
+
# The git prompt's git commands are read-only and should not interfere with
# other processes. This environment variable is equivalent to running with `git
# --no-optional-locks`, but falls back gracefully for older versions of git.
@@ -37,8 +39,10 @@ function _omz_git_prompt_info() {
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
-# Enable async prompt by default unless the setting is at false / no
-if zstyle -T ':omz:alpha:lib:git' async-prompt; then
+# Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6
+# https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268
+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() {
setopt localoptions noksharrays
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then