install.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. set -e
  2. CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
  3. if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
  4. echo "\033[0;33m Zsh is not installed!\033[0m Please install zsh first!"
  5. exit
  6. fi
  7. unset CHECK_ZSH_INSTALLED
  8. if [ ! -n "$ZSH" ]; then
  9. ZSH=~/.oh-my-zsh
  10. fi
  11. if [ -d "$ZSH" ]; then
  12. echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install"
  13. exit
  14. fi
  15. # Prevent the cloned repository from having insecure permissions. Failing to do
  16. # so causes compinit() calls to fail with "command not found: compdef" errors
  17. # for users with insecure umasks (e.g., "002", allowing group writability). Note
  18. # that this will be ignored under Cygwin by default, as Windows ACLs take
  19. # precedence over umasks except for filesystems mounted with option "noacl".
  20. umask g-w,o-w
  21. echo "\033[0;34mCloning Oh My Zsh...\033[0m"
  22. hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
  23. echo "git not installed"
  24. exit
  25. }
  26. echo "\033[0;34mLooking for an existing zsh config...\033[0m"
  27. if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
  28. echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
  29. mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
  30. fi
  31. echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
  32. cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
  33. sed "/^export ZSH=/ c\\
  34. export ZSH=$ZSH
  35. " ~/.zshrc > ~/.zshrc-omztemp
  36. mv -f ~/.zshrc-omztemp ~/.zshrc
  37. echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
  38. sed "/export PATH=/ c\\
  39. export PATH=\"$PATH\"
  40. " ~/.zshrc > ~/.zshrc-omztemp
  41. mv -f ~/.zshrc-omztemp ~/.zshrc
  42. # If this user's login shell is not already "zsh", attempt to switch.
  43. if [ "$(expr "$SHELL" : '.*/\(.*\)')" != "zsh" ]; then
  44. # If this platform provides a "chsh" command (not Cygwin), do it, man!
  45. if hash chsh >/dev/null 2>&1; then
  46. echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
  47. chsh -s $(grep /zsh$ /etc/shells | tail -1)
  48. # Else, suggest the user do so manually.
  49. else
  50. echo "\033[0;34mPlease manually change your default shell to zsh!\033[0m"
  51. fi
  52. fi
  53. echo "\033[0;32m"' __ __ '"\033[0m"
  54. echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
  55. echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
  56. echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
  57. echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
  58. echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m"
  59. echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m"
  60. echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m"
  61. echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m"
  62. env zsh
  63. . ~/.zshrc