diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/check_for_upgrade.sh | 15 | ||||
-rwxr-xr-x | tools/install.sh | 43 | ||||
-rwxr-xr-x | tools/theme_chooser.sh | 3 | ||||
-rw-r--r-- | tools/uninstall.sh | 18 | ||||
-rw-r--r-- | tools/upgrade.sh | 7 |
5 files changed, 53 insertions, 33 deletions
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index bbd705a1e..0f8c9c391 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -14,6 +14,14 @@ function _upgrade_zsh() { _update_zsh_update } +epoch_target=$UPDATE_ZSH_DAYS +if [[ -z "$epoch_target" ]]; then + # Default to old behavior + epoch_target=13 +fi + +[ -f ~/.profile ] && source ~/.profile + if [ -f ~/.zsh-update ] then . ~/.zsh-update @@ -23,7 +31,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt 13 ] + if [ $epoch_diff -gt $epoch_target ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then @@ -32,9 +40,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 8ca427d2c..71e19a389 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,31 +1,36 @@ -if [ -d ~/.oh-my-zsh ] -then - echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install" +set -e + +if [ ! -n "$ZSH" ]; then + ZSH=~/.oh-my-zsh +fi + +if [ -d "$ZSH" ]; then + echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install" exit fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -which git > /dev/null -if [[ $? -eq 0 ]]; then - /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh -else +hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" exit -fi +} 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; +if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then + 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 +cp $ZSH/templates/zshrc.zsh-template ~/.zshrc +sed -i -e "/^ZSH=/ c\\ +ZSH=$ZSH +" ~/.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 +sed -i -e "/export PATH=/ c\\ +export PATH=\"$PATH\" +" ~/.zshrc echo "\033[0;34mTime to change your default shell to zsh!\033[0m" chsh -s `which zsh` @@ -35,8 +40,8 @@ echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" -echo "\033[0;32m"' /____/ '"\033[0m" - -echo "\n\n \033[0;32m....is now installed.\033[0m" +echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" +echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" +echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" /usr/bin/env zsh -source ~/.zshrc +. ~/.zshrc diff --git a/tools/theme_chooser.sh b/tools/theme_chooser.sh index 4d7047444..2c2a379ba 100755 --- a/tools/theme_chooser.sh +++ b/tools/theme_chooser.sh @@ -24,7 +24,8 @@ function theme_preview() { THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//` print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color" source "$THEMES_DIR/$THEME" - print -P $PROMPT + cols=$(tput cols) + print -P "$PROMPT $RPROMPT" } function banner() { 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..9a8497d96 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,8 +1,6 @@ -current_path=`pwd` printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" -cd $ZSH - -if git pull origin master +cd "$ZSH" +if git pull --rebase --stat origin master then printf '\033[0;32m%s\033[0m\n' ' __ __ ' printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' @@ -16,4 +14,3 @@ 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 |