From 27d1f410ab91434a5e65863082975b21ecb79f52 Mon Sep 17 00:00:00 2001 From: Andrew Vit Date: Mon, 23 Apr 2012 14:01:14 -0700 Subject: [PATCH 1/2] Accept alternate install paths via ZSH variable Uses environment variable $ZSH to configure install location. --- README.textile | 8 +++++++- tools/install.sh | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.textile b/README.textile index 86dd5da22..c73b27727 100644 --- a/README.textile +++ b/README.textile @@ -20,8 +20,14 @@ h4. via `wget` @wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@ -h3. The manual way +h4. Install location +You can change the install destination via the ZSH environment variable. The default location is `~/.oh-my-zsh`: + +@...install.sh | ZSH=~/.dotfiles sh@ + + +h3. The manual way 1. Clone the repository diff --git a/tools/install.sh b/tools/install.sh index a2bd5665a..d8606a2c0 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,11 +1,18 @@ -if [ -d ~/.oh-my-zsh ] +set -e + +if [ ! -n $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" + 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" -hash git >/dev/null && /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 $ZSH || { echo "git not installed" exit } @@ -18,7 +25,10 @@ then 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:$PATH" >> ~/.zshrc From 77f0110d5f551935df0dba43de8402c22fac064e Mon Sep 17 00:00:00 2001 From: Andrew Vit Date: Wed, 9 Nov 2011 16:58:45 -0800 Subject: [PATCH 2/2] Allow (re)installing from local repo If a local directory exists, perhaps a forked copy instead of the robbyrussell master, this allows the installer script to use it and continue the install process instead of exiting early. Changes the installer to continue even if the $ZSH directory is already installed. --- tools/install.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index d8606a2c0..1b60378a4 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -5,18 +5,15 @@ then ZSH=~/.oh-my-zsh fi -if [ -d $ZSH ] +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 + echo "\033[0;34mCloning Oh My Zsh...\033[0m" + 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;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { - echo "git not installed" - exit -} - echo "\033[0;34mLooking for an existing zsh config...\033[0m" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] then