2020-10-31 22:14:24 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2020-12-01 10:12:31 +00:00
|
|
|
if [ -z "$ZSH_VERSION" ]; then
|
2021-01-21 10:52:09 +00:00
|
|
|
exec zsh "$0" "$@"
|
2020-12-01 10:12:31 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-31 22:14:24 +00:00
|
|
|
cd "$ZSH"
|
|
|
|
|
|
|
|
# Use colors, but only if connected to a terminal
|
|
|
|
# and that terminal supports them.
|
|
|
|
|
|
|
|
local -a RAINBOW
|
2020-12-12 12:41:29 +00:00
|
|
|
local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
|
2020-10-31 22:14:24 +00:00
|
|
|
|
2020-03-11 13:24:04 +00:00
|
|
|
if [ -t 1 ]; then
|
2020-10-31 22:14:24 +00:00
|
|
|
RAINBOW=(
|
|
|
|
"$(printf '\033[38;5;196m')"
|
|
|
|
"$(printf '\033[38;5;202m')"
|
|
|
|
"$(printf '\033[38;5;226m')"
|
|
|
|
"$(printf '\033[38;5;082m')"
|
|
|
|
"$(printf '\033[38;5;021m')"
|
|
|
|
"$(printf '\033[38;5;093m')"
|
|
|
|
"$(printf '\033[38;5;163m')"
|
|
|
|
)
|
2020-05-18 09:23:28 +00:00
|
|
|
|
2020-03-11 13:24:04 +00:00
|
|
|
RED=$(printf '\033[31m')
|
|
|
|
GREEN=$(printf '\033[32m')
|
|
|
|
YELLOW=$(printf '\033[33m')
|
|
|
|
BLUE=$(printf '\033[34m')
|
|
|
|
BOLD=$(printf '\033[1m')
|
2020-12-12 12:41:29 +00:00
|
|
|
DIM=$(printf '\033[2m')
|
2020-08-17 19:47:39 +00:00
|
|
|
UNDER=$(printf '\033[4m')
|
2020-03-11 13:24:04 +00:00
|
|
|
RESET=$(printf '\033[m')
|
2015-07-07 00:18:32 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-31 22:14:24 +00:00
|
|
|
# Update upstream remote to ohmyzsh org
|
2020-12-02 10:57:37 +00:00
|
|
|
git remote -v | while read remote url extra; do
|
2020-10-31 22:14:24 +00:00
|
|
|
case "$url" in
|
|
|
|
https://github.com/robbyrussell/oh-my-zsh(|.git))
|
|
|
|
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
|
|
|
|
break ;;
|
|
|
|
git@github.com:robbyrussell/oh-my-zsh(|.git))
|
|
|
|
git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git"
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
2019-10-21 14:42:06 +00:00
|
|
|
|
|
|
|
# Set git-config values known to fix git errors
|
|
|
|
# Line endings (#4069)
|
|
|
|
git config core.eol lf
|
|
|
|
git config core.autocrlf false
|
|
|
|
# zeroPaddedFilemode fsck errors (#4963)
|
|
|
|
git config fsck.zeroPaddedFilemode ignore
|
|
|
|
git config fetch.fsck.zeroPaddedFilemode ignore
|
|
|
|
git config receive.fsck.zeroPaddedFilemode ignore
|
2020-03-11 13:17:41 +00:00
|
|
|
# autostash on rebase (#7172)
|
2020-10-31 22:14:24 +00:00
|
|
|
resetAutoStash=$(git config --bool rebase.autoStash 2>/dev/null)
|
2020-03-11 13:17:41 +00:00
|
|
|
git config rebase.autoStash true
|
2019-10-21 14:42:06 +00:00
|
|
|
|
2020-10-31 22:14:24 +00:00
|
|
|
local ret=0
|
2019-11-21 01:26:18 +00:00
|
|
|
|
2020-10-31 22:14:24 +00:00
|
|
|
# Update Oh My Zsh
|
2020-05-19 12:47:30 +00:00
|
|
|
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
2020-10-31 22:14:24 +00:00
|
|
|
last_commit=$(git rev-parse HEAD)
|
|
|
|
if git pull --rebase --stat origin master; then
|
|
|
|
# Check if it was really updated or not
|
|
|
|
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
|
|
|
message="Oh My Zsh is already at the latest version."
|
|
|
|
else
|
|
|
|
message="Hooray! Oh My Zsh has been updated!"
|
2020-10-31 23:26:03 +00:00
|
|
|
|
2020-12-12 12:41:29 +00:00
|
|
|
# Save the commit prior to updating
|
|
|
|
git config oh-my-zsh.lastVersion "$last_commit"
|
|
|
|
|
2021-06-12 03:03:21 +00:00
|
|
|
# Print changelog to the terminal
|
2020-12-07 18:53:07 +00:00
|
|
|
if [[ "$1" = --interactive ]]; then
|
2020-12-28 18:35:43 +00:00
|
|
|
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
|
2020-10-31 23:26:03 +00:00
|
|
|
fi
|
2020-12-12 12:41:29 +00:00
|
|
|
|
2020-12-28 18:35:43 +00:00
|
|
|
printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
|
2020-10-31 22:14:24 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
printf '\n'
|
|
|
|
printf "${BLUE}%s${RESET}\n" "$message"
|
|
|
|
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
|
2020-08-17 19:47:39 +00:00
|
|
|
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
|
|
|
|
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
|
2012-01-15 06:49:52 +00:00
|
|
|
else
|
2020-10-31 22:14:24 +00:00
|
|
|
ret=$?
|
2020-03-11 13:24:04 +00:00
|
|
|
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
2012-01-15 06:49:52 +00:00
|
|
|
fi
|
2020-03-11 13:17:41 +00:00
|
|
|
|
|
|
|
# Unset git-config values set just for the upgrade
|
|
|
|
case "$resetAutoStash" in
|
|
|
|
"") git config --unset rebase.autoStash ;;
|
|
|
|
*) git config rebase.autoStash "$resetAutoStash" ;;
|
|
|
|
esac
|
2020-09-09 09:07:46 +00:00
|
|
|
|
|
|
|
# Exit with `1` if the update failed
|
2020-10-31 22:14:24 +00:00
|
|
|
exit $ret
|