From 152aab69bc0e0017d85518ed427df3beb201dea6 Mon Sep 17 00:00:00 2001 From: Andrew Vit Date: Sat, 8 Mar 2014 23:24:59 -0800 Subject: [PATCH] Respect original PATH definitions on install The exporting of PATH as a fixed string would clobber any system-wide paths added to env after installation. Instead, we now read any existing PATH exports from previous config files and copy those from the user's bash config, or else default to a basic prepend-only example that respects the system environment. --- tools/install.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index a53ac48ab..3f7e621b9 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -23,14 +23,23 @@ 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\\ +sed -e "/^ZSH=/ c\\ ZSH=$ZSH -" ~/.zshrc +" ~/.zshrc | tee ~/.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\\ -export PATH=\"$PATH\" -" ~/.zshrc +ORIG_RC_FILES=`ls ~/.bashrc ~/.zshrc.pre-oh-my-zsh 2>/dev/null` || : +if [ "$ORIG_RC_FILES" ] +then + ORIG_PATHS=`grep -sh '^export PATH=' $ORIG_RC_FILES` || : +fi + +if [ "$ORIG_PATHS" ] +then + echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" + nl=$'\n' + sed -e '/^export PATH=/ c\ +'"${ORIG_PATHS//$nl/\\$nl}" ~/.zshrc | tee ~/.zshrc +fi if [ "$SHELL" != "$(which zsh)" ]; then echo "\033[0;34mTime to change your default shell to zsh!\033[0m"