From 56cfcb44e7ff730c10c5a00b58f38c33c984c52e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 18 Apr 2024 07:33:13 +0200 Subject: fix(updater): abort update if `$ZSH` is not a git repository Fixes #12298 --- tools/check_for_upgrade.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tools/check_for_upgrade.sh') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1cc193bde..a5d2112f6 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || { } # Cancel update if: -# - the automatic update is disabled. -# - the current user doesn't have write permissions nor owns the $ZSH directory. +# - the automatic update is disabled +# - the current user doesn't have write permissions nor owns the $ZSH directory # - is not run from a tty -# - git is unavailable on the system. +# - git is unavailable on the system +# - $ZSH is not a git repository if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -t 1 ]] \ - || ! command git --version 2>&1 >/dev/null; then + || ! command git --version 2>&1 >/dev/null + || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then unset update_mode return fi -- cgit v1.2.3-70-g09d2 From 80a651a6dfafc40630b47ad2f173d326844d6925 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 18 Apr 2024 07:48:33 +0200 Subject: chore(updater): small typo --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/check_for_upgrade.sh') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index a5d2112f6..1ecab5c0b 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -28,7 +28,7 @@ zstyle -s ':omz:update' mode update_mode || { if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -t 1 ]] \ - || ! command git --version 2>&1 >/dev/null + || ! command git --version 2>&1 >/dev/null \ || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then unset update_mode return -- cgit v1.2.3-70-g09d2 From 7d32e7fc3fb56032252548a690744a26c3ac3059 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Feb 2025 12:22:23 +0100 Subject: fix(updater): detect p10k instant prompt (#12971) Fixes #12781 --- tools/check_for_upgrade.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools/check_for_upgrade.sh') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1ecab5c0b..35391ea70 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -27,7 +27,7 @@ zstyle -s ':omz:update' mode update_mode || { # - $ZSH is not a git repository if [[ "$update_mode" = disabled ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ - || [[ ! -t 1 ]] \ + || [[ ! -t 1 && ${POWERLEVEL9K_INSTANT_PROMPT:-off} == off ]] \ || ! command git --version 2>&1 >/dev/null \ || (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then unset update_mode @@ -112,6 +112,11 @@ function update_ohmyzsh() { local verbose_mode zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default + # Force verbose mode to silent if p10k instant prompt is enabled + if [[ ${POWERLEVEL9K_INSTANT_PROMPT:-off} != "off" ]]; then + verbose_mode=silent + fi + if [[ "$update_mode" != background-alpha ]] \ && LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then update_last_updated_file -- cgit v1.2.3-70-g09d2 From d3888251acae61f0ce2c7a780e97a5d2f406bd9f Mon Sep 17 00:00:00 2001 From: Paul Frederiksen Date: Fri, 19 Sep 2025 06:47:45 -0700 Subject: fix(check_for_upgrade): ensure compatibility with screen (#13302) Co-authored-by: Paul Frederiksen --- tools/check_for_upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/check_for_upgrade.sh') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 35391ea70..44dbb7b31 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -232,7 +232,7 @@ function handle_update() { # Ask for confirmation and only update on 'y', 'Y' or Enter # Otherwise just show a reminder for how to update - echo -n "[oh-my-zsh] Would you like to update? [Y/n] " + printf "[oh-my-zsh] Would you like to update? [Y/n] " read -r -k 1 option [[ "$option" = $'\n' ]] || echo case "$option" in @@ -280,7 +280,7 @@ case "$update_mode" in return 0 elif [[ "$EXIT_STATUS" -ne 0 ]]; then print -P "\n%F{red}[oh-my-zsh] There was an error updating:%f" - printf "\n${fg[yellow]}%s${reset_color}" "$ERROR" + printf "\n${fg[yellow]}%s${reset_color}" "${ERROR}" return 0 fi } always { -- cgit v1.2.3-70-g09d2