diff --git a/tools/install.sh b/tools/install.sh
index d210d8cc97d63eb998c21a3f6578c7aa01c80b3d..731d89a2997a23669b72d0c0fa11174117a6f59e 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -250,9 +250,9 @@ setup_zshrc() {
 
   echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
 
-  sed "/^export ZSH=/ c\\
-export ZSH=\"${ZSH/$HOME\//\$HOME\/}\"
-" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
+  # Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
+  omz=$(echo "$ZSH" | sed "s|^$HOME/|\$HOME/|")
+  sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
   mv -f ~/.zshrc-omztemp ~/.zshrc
 
   echo