From 5b427df37dbfa9d33059679abad81a185415504d Mon Sep 17 00:00:00 2001 From: Nabin Nepal Date: Wed, 20 Jun 2018 11:01:15 +0100 Subject: [PATCH 1/3] Supports custom home folder path This allows Oh My Zsh to be installed by root for another user. Useful when using tools like Chef and Ansible to setup a system. --- tools/install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index b815a9c81..38d1396cd 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -29,8 +29,12 @@ main() { exit fi + if [ ! -n "$ZSH_PATH" ]; then + ZSH_PATH=~ + fi + if [ ! -n "$ZSH" ]; then - ZSH=~/.oh-my-zsh + ZSH=$ZSH_PATH/.oh-my-zsh fi if [ -d "$ZSH" ]; then @@ -66,17 +70,17 @@ main() { printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n" - if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then - printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n"; - mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh; + if [ -f $ZSH_PATH/.zshrc ] || [ -h $ZSH_PATH/.zshrc ]; then + printf "${YELLOW}Found $ZSH_PATH/.zshrc.${NORMAL} ${GREEN}Backing up to $ZSH_PATH/.zshrc.pre-oh-my-zsh${NORMAL}\n"; + mv $ZSH_PATH/.zshrc $ZSH_PATH/.zshrc.pre-oh-my-zsh; fi - printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n" - cp "$ZSH"/templates/zshrc.zsh-template ~/.zshrc + printf "${BLUE}Using the Oh My Zsh template file and adding it to $ZSH_PATH/.zshrc${NORMAL}\n" + cp "$ZSH"/templates/zshrc.zsh-template $ZSH_PATH/.zshrc sed "/^export ZSH=/ c\\ export ZSH=\"$ZSH\" - " ~/.zshrc > ~/.zshrc-omztemp - mv -f ~/.zshrc-omztemp ~/.zshrc + " $ZSH_PATH/.zshrc > $ZSH_PATH/.zshrc-omztemp + mv -f $ZSH_PATH/.zshrc-omztemp $ZSH_PATH/.zshrc # If this user's login shell is not already "zsh", attempt to switch. TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') @@ -101,7 +105,7 @@ main() { echo ' /____/ ....is now installed!' echo '' echo '' - echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.' + echo 'Please look over the $ZSH_PATH/.zshrc file to select plugins, themes, and options.' echo '' echo 'p.s. Follow us at https://twitter.com/ohmyzsh.' echo '' From 7742ca25667137aa27c3764789607552f118626c Mon Sep 17 00:00:00 2001 From: Nabin Nepal Date: Wed, 20 Jun 2018 11:09:43 +0100 Subject: [PATCH 2/3] Updated readme with me custom ZSHRC path --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b3651a99c..9fb1c70b3 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,15 @@ If you'd like to change the install directory with the `ZSH` environment variabl ```shell export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" ``` +#### Custom Configuration folder + +The default folder is `~` (hidden in your home directory) + +If you'd like to install for a different user in a custom home folder path, you can specify that with `ZSHRC_PATH` environment variable, either by running `export ZSHRC_PATH=/home/custom_user` before installing, or by setting it before the end of the install pipeline like this: + +```shell +export ZSHRC_PATH="/home/custom_user"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" +``` #### Manual Installation From 8df6fec62291e109248003e831d20af3506f92f6 Mon Sep 17 00:00:00 2001 From: Nabin Nepal Date: Wed, 20 Jun 2018 11:10:47 +0100 Subject: [PATCH 3/3] Used more correct variable name --- tools/install.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 38d1396cd..70e654532 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -29,12 +29,12 @@ main() { exit fi - if [ ! -n "$ZSH_PATH" ]; then - ZSH_PATH=~ + if [ ! -n "$ZSHRC_PATH" ]; then + ZSHRC_PATH=~ fi if [ ! -n "$ZSH" ]; then - ZSH=$ZSH_PATH/.oh-my-zsh + ZSH=$ZSHRC_PATH/.oh-my-zsh fi if [ -d "$ZSH" ]; then @@ -70,17 +70,17 @@ main() { printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n" - if [ -f $ZSH_PATH/.zshrc ] || [ -h $ZSH_PATH/.zshrc ]; then - printf "${YELLOW}Found $ZSH_PATH/.zshrc.${NORMAL} ${GREEN}Backing up to $ZSH_PATH/.zshrc.pre-oh-my-zsh${NORMAL}\n"; - mv $ZSH_PATH/.zshrc $ZSH_PATH/.zshrc.pre-oh-my-zsh; + if [ -f $ZSHRC_PATH/.zshrc ] || [ -h $ZSHRC_PATH/.zshrc ]; then + printf "${YELLOW}Found $ZSHRC_PATH/.zshrc.${NORMAL} ${GREEN}Backing up to $ZSHRC_PATH/.zshrc.pre-oh-my-zsh${NORMAL}\n"; + mv $ZSHRC_PATH/.zshrc $ZSHRC_PATH/.zshrc.pre-oh-my-zsh; fi - printf "${BLUE}Using the Oh My Zsh template file and adding it to $ZSH_PATH/.zshrc${NORMAL}\n" - cp "$ZSH"/templates/zshrc.zsh-template $ZSH_PATH/.zshrc + printf "${BLUE}Using the Oh My Zsh template file and adding it to $ZSHRC_PATH/.zshrc${NORMAL}\n" + cp "$ZSH"/templates/zshrc.zsh-template $ZSHRC_PATH/.zshrc sed "/^export ZSH=/ c\\ export ZSH=\"$ZSH\" - " $ZSH_PATH/.zshrc > $ZSH_PATH/.zshrc-omztemp - mv -f $ZSH_PATH/.zshrc-omztemp $ZSH_PATH/.zshrc + " $ZSHRC_PATH/.zshrc > $ZSHRC_PATH/.zshrc-omztemp + mv -f $ZSHRC_PATH/.zshrc-omztemp $ZSHRC_PATH/.zshrc # If this user's login shell is not already "zsh", attempt to switch. TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') @@ -105,7 +105,7 @@ main() { echo ' /____/ ....is now installed!' echo '' echo '' - echo 'Please look over the $ZSH_PATH/.zshrc file to select plugins, themes, and options.' + echo 'Please look over the $ZSHRC_PATH/.zshrc file to select plugins, themes, and options.' echo '' echo 'p.s. Follow us at https://twitter.com/ohmyzsh.' echo ''