summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/check_for_upgrade.sh7
-rwxr-xr-xtools/install.sh39
-rw-r--r--tools/upgrade.sh2
3 files changed, 34 insertions, 14 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 4a0803210..5afd83c1e 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then
epoch_target=13
fi
-[ -f ~/.profile ] && source ~/.profile
-
# Cancel upgrade if the current user doesn't have write permissions for the
# oh-my-zsh directory.
[[ -w "$ZSH" ]] || return 0
@@ -43,10 +41,9 @@ then
then
_upgrade_zsh
else
- echo "[Oh My Zsh] Would you like to check for updates?"
- echo "Type Y to update oh-my-zsh: \c"
+ echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c"
read line
- if [ "$line" = Y ] || [ "$line" = y ]; then
+ if [ "$line" = Y ] || [ "$line" = y ] || [ -z "$line" ]; then
_upgrade_zsh
else
_update_zsh_update
diff --git a/tools/install.sh b/tools/install.sh
index a53ac48ab..aebd28371 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -1,5 +1,12 @@
set -e
+CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
+if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
+ echo "\033[0;33m Zsh is not installed!\033[0m Please install zsh first!"
+ exit
+fi
+unset CHECK_ZSH_INSTALLED
+
if [ ! -n "$ZSH" ]; then
ZSH=~/.oh-my-zsh
fi
@@ -9,8 +16,15 @@ if [ -d "$ZSH" ]; then
exit
fi
+# Prevent the cloned repository from having insecure permissions. Failing to do
+# so causes compinit() calls to fail with "command not found: compdef" errors
+# for users with insecure umasks (e.g., "002", allowing group writability). Note
+# that this will be ignored under Cygwin by default, as Windows ACLs take
+# precedence over umasks except for filesystems mounted with option "noacl".
+umask g-w,o-w
+
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
-hash git >/dev/null 2>&1 && env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
+hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
echo "git not installed"
exit
}
@@ -23,18 +37,27 @@ fi
echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
-sed -i -e "/^ZSH=/ c\\
-ZSH=$ZSH
-" ~/.zshrc
+sed "/^export ZSH=/ c\\
+export ZSH=$ZSH
+" ~/.zshrc > ~/.zshrc-omztemp
+mv -f ~/.zshrc-omztemp ~/.zshrc
echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
-sed -i -e "/export PATH=/ c\\
+sed "/export PATH=/ c\\
export PATH=\"$PATH\"
-" ~/.zshrc
+" ~/.zshrc > ~/.zshrc-omztemp
+mv -f ~/.zshrc-omztemp ~/.zshrc
-if [ "$SHELL" != "$(which zsh)" ]; then
+# If this user's login shell is not already "zsh", attempt to switch.
+if [ "$(expr "$SHELL" : '.*/\(.*\)')" != "zsh" ]; then
+ # If this platform provides a "chsh" command (not Cygwin), do it, man!
+ if hash chsh >/dev/null 2>&1; then
echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
- chsh -s `which zsh`
+ chsh -s $(grep /zsh$ /etc/shells | tail -1)
+ # Else, suggest the user do so manually.
+ else
+ echo "\033[0;34mPlease manually change your default shell to zsh!\033[0m"
+ fi
fi
echo "\033[0;32m"' __ __ '"\033[0m"
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 5f0a81f1d..e06e4f331 100644
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -9,7 +9,7 @@ then
printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
printf '\033[0;32m%s\033[0m\n' ' /____/ '
printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
- printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh'
+ printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'https://twitter.com/ohmyzsh'
printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/'
else
printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'