mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-11 00:10:08 +00:00
feat(updater): do not update when user already typed some characters (#9699)
Fixes #9699
This commit is contained in:
parent
1e26ad1187
commit
f0f42828fa
1 changed files with 26 additions and 17 deletions
|
@ -146,26 +146,35 @@ function update_ohmyzsh() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask for confirmation before updating unless in auto mode
|
# Don't ask for confirmation before updating if in auto mode
|
||||||
if [[ "$update_mode" = auto ]]; then
|
if [[ "$update_mode" = auto ]]; then
|
||||||
update_ohmyzsh
|
update_ohmyzsh
|
||||||
elif [[ "$update_mode" = reminder ]]; then
|
return $?
|
||||||
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
|
fi
|
||||||
else
|
|
||||||
# input sink to swallow all characters typed before the prompt
|
|
||||||
# and add a newline if there wasn't one after characters typed
|
|
||||||
while read -t -k 1 option; do true; done
|
|
||||||
[[ "$option" != ($'\n'|"") ]] && echo
|
|
||||||
|
|
||||||
|
# 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 read -t -k 1; 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] "
|
echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
|
||||||
read -r -k 1 option
|
read -r -k 1 option
|
||||||
[[ "$option" != $'\n' ]] && echo
|
[[ "$option" = $'\n' ]] || echo
|
||||||
case "$option" in
|
case "$option" in
|
||||||
[yY$'\n']) update_ohmyzsh ;;
|
[yY$'\n']) update_ohmyzsh ;;
|
||||||
[nN]) update_last_updated_file ;&
|
[nN]) update_last_updated_file ;&
|
||||||
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
|
*) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset update_mode
|
unset update_mode
|
||||||
|
|
Loading…
Reference in a new issue