upgrade.sh 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Use colors, but only if connected to a terminal, and that terminal
  2. # supports them.
  3. if [ -t 1 ]; then
  4. RB_RED=$(printf '\033[38;5;196m')
  5. RB_ORANGE=$(printf '\033[38;5;202m')
  6. RB_YELLOW=$(printf '\033[38;5;226m')
  7. RB_GREEN=$(printf '\033[38;5;082m')
  8. RB_BLUE=$(printf '\033[38;5;021m')
  9. RB_INDIGO=$(printf '\033[38;5;093m')
  10. RB_VIOLET=$(printf '\033[38;5;163m')
  11. RED=$(printf '\033[31m')
  12. GREEN=$(printf '\033[32m')
  13. YELLOW=$(printf '\033[33m')
  14. BLUE=$(printf '\033[34m')
  15. BOLD=$(printf '\033[1m')
  16. UNDER=$(printf '\033[4m')
  17. RESET=$(printf '\033[m')
  18. else
  19. RB_RED=""
  20. RB_ORANGE=""
  21. RB_YELLOW=""
  22. RB_GREEN=""
  23. RB_BLUE=""
  24. RB_INDIGO=""
  25. RB_VIOLET=""
  26. RED=""
  27. GREEN=""
  28. YELLOW=""
  29. BLUE=""
  30. UNDER=""
  31. BOLD=""
  32. RESET=""
  33. fi
  34. cd "$ZSH"
  35. # Set git-config values known to fix git errors
  36. # Line endings (#4069)
  37. git config core.eol lf
  38. git config core.autocrlf false
  39. # zeroPaddedFilemode fsck errors (#4963)
  40. git config fsck.zeroPaddedFilemode ignore
  41. git config fetch.fsck.zeroPaddedFilemode ignore
  42. git config receive.fsck.zeroPaddedFilemode ignore
  43. # autostash on rebase (#7172)
  44. resetAutoStash=$(git config --bool rebase.autoStash 2>&1)
  45. git config rebase.autoStash true
  46. # Update upstream remote to ohmyzsh org
  47. remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
  48. if [ -n "$remote" ]; then
  49. git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
  50. fi
  51. printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
  52. if git pull --rebase --stat origin master
  53. then
  54. printf '%s %s__ %s %s %s %s %s__ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  55. printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  56. printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ ___/%s __ \ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  57. printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  58. printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  59. printf '%s %s %s %s /____/ %s %s %s %s\n' $RB_RED $RB_ORANGE $RB_YELLOW $RB_GREEN $RB_BLUE $RB_INDIGO $RB_VIOLET $RB_RESET
  60. printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
  61. printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up on the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
  62. printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
  63. printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
  64. else
  65. status=$?
  66. printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
  67. fi
  68. # Unset git-config values set just for the upgrade
  69. case "$resetAutoStash" in
  70. "") git config --unset rebase.autoStash ;;
  71. *) git config rebase.autoStash "$resetAutoStash" ;;
  72. esac
  73. # Exit with `1` if the update failed
  74. exit $status