upgrade.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Use colors, but only if connected to a terminal, and that terminal
  2. # supports them.
  3. if [ -t 1 ]; then
  4. RED=$(printf '\033[31m')
  5. GREEN=$(printf '\033[32m')
  6. YELLOW=$(printf '\033[33m')
  7. BLUE=$(printf '\033[34m')
  8. BOLD=$(printf '\033[1m')
  9. RESET=$(printf '\033[m')
  10. else
  11. RED=""
  12. GREEN=""
  13. YELLOW=""
  14. BLUE=""
  15. BOLD=""
  16. RESET=""
  17. fi
  18. cd "$ZSH"
  19. # Set git-config values known to fix git errors
  20. # Line endings (#4069)
  21. git config core.eol lf
  22. git config core.autocrlf false
  23. # zeroPaddedFilemode fsck errors (#4963)
  24. git config fsck.zeroPaddedFilemode ignore
  25. git config fetch.fsck.zeroPaddedFilemode ignore
  26. git config receive.fsck.zeroPaddedFilemode ignore
  27. # autostash on rebase (#7172)
  28. resetAutoStash=$(git config --bool rebase.autoStash 2>&1)
  29. git config rebase.autoStash true
  30. # Update upstream remote to ohmyzsh org
  31. remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
  32. if [ -n "$remote" ]; then
  33. git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
  34. fi
  35. printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
  36. if git pull --rebase --stat origin master
  37. then
  38. printf '%s' "$GREEN"
  39. printf '%s\n' ' __ __ '
  40. printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
  41. printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
  42. printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
  43. printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
  44. printf '%s\n' ' /____/ '
  45. printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
  46. printf "${BLUE}${BOLD}%s${RESET}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
  47. printf "${BLUE}${BOLD}%s${RESET}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/collections/oh-my-zsh"
  48. else
  49. printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
  50. fi
  51. # Unset git-config values set just for the upgrade
  52. case "$resetAutoStash" in
  53. "") git config --unset rebase.autoStash ;;
  54. *) git config rebase.autoStash "$resetAutoStash" ;;
  55. esac