diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/check_for_upgrade.sh | 13 | ||||
-rwxr-xr-x | tools/install.sh | 12 | ||||
-rw-r--r-- | tools/uninstall.sh | 18 | ||||
-rw-r--r-- | tools/upgrade.sh | 5 |
4 files changed, 33 insertions, 15 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 524aa509d..581f03a07 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -14,6 +14,12 @@ function _upgrade_zsh() { _update_zsh_update } +epoch_target=$UPDATE_ZSH_DAYS +if [[ -z "$epoch_target" ]]; then + # Default to old behavior + epoch_target=13 +fi + if [ -f ~/.zsh-update ] then . ~/.zsh-update @@ -23,7 +29,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt 6 ] + if [ $epoch_diff -gt $epoch_target ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then @@ -32,9 +38,10 @@ then echo "[Oh My Zsh] Would you like to check for updates?" echo "Type Y to update oh-my-zsh: \c" read line - if [ "$line" = Y ] || [ "$line" = y ] - then + if [ "$line" = Y ] || [ "$line" = y ]; then _upgrade_zsh + else + _update_zsh_update fi fi fi diff --git a/tools/install.sh b/tools/install.sh index aedb706da..a2bd5665a 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -5,21 +5,23 @@ then fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh +hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh || { + echo "git not installed" + exit +} echo "\033[0;34mLooking for an existing zsh config...\033[0m" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] then - echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m"; - cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; - rm ~/.zshrc; + echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m"; + mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh; fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" -echo "export PATH=$PATH" >> ~/.zshrc +echo "export PATH=\$PATH:$PATH" >> ~/.zshrc echo "\033[0;34mTime to change your default shell to zsh!\033[0m" chsh -s `which zsh` diff --git a/tools/uninstall.sh b/tools/uninstall.sh index 8ff583322..41d601576 100644 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -4,12 +4,20 @@ then rm -rf ~/.oh-my-zsh fi -echo "Looking for an existing zsh config..." +echo "Looking for original zsh config..." if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ] then - echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; - rm ~/.zshrc; - cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc; + echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc"; + + if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] + then + ZSHRC_SAVE=".zshrc.omz-uninstalled-`date +%Y%m%d%H%M%S`"; + echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}"; + mv ~/.zshrc ~/${ZSHRC_SAVE}; + fi + + mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc; + source ~/.zshrc; else echo "Switching back to bash" @@ -17,4 +25,4 @@ else source /etc/profile fi -echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
\ No newline at end of file +echo "Thanks for trying out Oh My Zsh. It's been uninstalled." diff --git a/tools/upgrade.sh b/tools/upgrade.sh index b2a1c06c4..0aeebdebf 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,6 +1,7 @@ current_path=`pwd` +current_path=${current_path/ /\\ } printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" -cd $ZSH +cd "$ZSH" if git pull origin master then @@ -16,4 +17,4 @@ else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' fi -cd "$current_path"
\ No newline at end of file +cd "$current_path" |