mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
feat(upgrade): add verbosity settings
Co-authored-by: Carlo Sala <carlosalag@protonmail.com> Closes #11574 Closes #11579
This commit is contained in:
parent
c08b925d28
commit
8f6fbe2389
4 changed files with 56 additions and 17 deletions
12
README.md
12
README.md
|
@ -317,6 +317,18 @@ zstyle ':omz:update' frequency 7
|
||||||
zstyle ':omz:update' frequency 0
|
zstyle ':omz:update' frequency 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Updates verbosity
|
||||||
|
|
||||||
|
You can also limit the update verbosity with the following settings:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zstyle ':omz:update' verbose default # default update prompt
|
||||||
|
|
||||||
|
zstyle ':omz:update' verbose minimal # only few lines
|
||||||
|
|
||||||
|
zstyle ':omz:update' verbose silent # only errors
|
||||||
|
```
|
||||||
|
|
||||||
### Manual Updates
|
### Manual Updates
|
||||||
|
|
||||||
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
||||||
|
|
|
@ -776,10 +776,11 @@ function _omz::update {
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
if [[ "$1" != --unattended ]]; then
|
if [[ "$1" != --unattended ]]; then
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
|
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||||
else
|
else
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
|
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update last updated file
|
# Update last updated file
|
||||||
|
|
|
@ -95,7 +95,8 @@ function update_last_updated_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_ohmyzsh() {
|
function update_ohmyzsh() {
|
||||||
if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
|
if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then
|
||||||
update_last_updated_file
|
update_last_updated_file
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,23 @@ esac
|
||||||
|
|
||||||
cd "$ZSH"
|
cd "$ZSH"
|
||||||
|
|
||||||
|
verbose_mode="default"
|
||||||
|
interactive=false
|
||||||
|
|
||||||
|
while getopts "v:i" opt; do
|
||||||
|
case $opt in
|
||||||
|
v)
|
||||||
|
if [[ $OPTARG == default || $OPTARG == minimal || $OPTARG == silent ]]; then
|
||||||
|
verbose_mode=$OPTARG
|
||||||
|
else
|
||||||
|
echo "[oh-my-zsh] update verbosity '$OPTARG' is not valid"
|
||||||
|
echo "[oh-my-zsh] valid options are 'default', 'minimal' and 'silent'"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
i) interactive=true ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# Use colors, but only if connected to a terminal
|
# Use colors, but only if connected to a terminal
|
||||||
# and that terminal supports them.
|
# and that terminal supports them.
|
||||||
|
|
||||||
|
@ -203,7 +220,9 @@ git checkout -q "$branch" -- || exit 1
|
||||||
last_commit=$(git rev-parse "$branch")
|
last_commit=$(git rev-parse "$branch")
|
||||||
|
|
||||||
# Update Oh My Zsh
|
# Update Oh My Zsh
|
||||||
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
if [[ $verbose_mode != silent ]]; then
|
||||||
|
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
||||||
|
fi
|
||||||
if LANG= git pull --quiet --rebase $remote $branch; then
|
if LANG= git pull --quiet --rebase $remote $branch; then
|
||||||
# Check if it was really updated or not
|
# Check if it was really updated or not
|
||||||
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
||||||
|
@ -215,13 +234,16 @@ if LANG= git pull --quiet --rebase $remote $branch; then
|
||||||
git config oh-my-zsh.lastVersion "$last_commit"
|
git config oh-my-zsh.lastVersion "$last_commit"
|
||||||
|
|
||||||
# Print changelog to the terminal
|
# Print changelog to the terminal
|
||||||
if [[ "$1" = --interactive ]]; then
|
if [[ interactive == true && $verbose_mode == default ]] ; then
|
||||||
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
|
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $verbose_mode != silent ]]; then
|
||||||
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $verbose_mode == default ]]; then
|
||||||
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
|
printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
|
||||||
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
|
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
|
||||||
printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
|
printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
|
||||||
|
@ -233,6 +255,9 @@ if LANG= git pull --quiet --rebase $remote $branch; then
|
||||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
||||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
|
||||||
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
|
||||||
|
elif [[ $verbose_mode == minimal ]]; then
|
||||||
|
printf "${BLUE}%s${RESET}\n" "$message"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
ret=$?
|
ret=$?
|
||||||
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
||||||
|
|
Loading…
Reference in a new issue