1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 06:42:28 +08:00

feat(updater): check for typed input before automatically updating (#10830)

This commit is contained in:
Marc Cornellà 2022-04-10 10:20:51 +02:00 committed by GitHub
parent fcceeb6664
commit 846f417eb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,25 +180,19 @@ function has_typed_input() {
return
fi
# If in reminder mode or user has typed input, show reminder and exit
if [[ "$update_mode" = reminder ]] || has_typed_input; then
printf '\r\e[0K' # move cursor to first column and clear whole line
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0
fi
# Don't ask for confirmation before updating if in auto mode
if [[ "$update_mode" = auto ]]; then
update_ohmyzsh
return $?
fi
# If in reminder mode show reminder and exit
if [[ "$update_mode" = reminder ]]; then
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0
fi
# If user has typed input, show reminder and exit
if has_typed_input; then
echo
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
return 0
fi
# 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] "