Search code examples
bashoh-my-zsh

Bash script exits early after installing oh my zsh


I'm trying to install oh my zsh and a few other commands using a bash script.

However, after installing oh my zsh, the bash script exits without running the rest of the script.

Bash script snippet:

echo Installing Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo Installing zeit theme
curl https://raw.githubusercontent.com/vercel/zsh-theme/master/vercel.zsh-theme -Lo ~/.oh-my-zsh/custom/themes/vercel.zsh-theme
echo Installing Node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.zshrc
nvm install node
nvm use node
npm install -g yarn

Is there a way for me to maybe prevent the oh my zsh install script to exit when the installation is complete.

Thanks !


Solution

  • Oh My Zsh provides an "Unattended Install" Option: https://github.com/ohmyzsh/ohmyzsh#unattended-install

    According to the docs:

    If you're running the Oh My Zsh install script as part of an automated install, you can pass the flag --unattended to the install.sh script. This will have the effect of not trying to change the default shell, and also won't run zsh when the installation has finished.

    In my case, the script in use had a small mistake.

    Required:

    bash -c "... curl command ..." "" --unattended
    

    What was there:

    bash -c "... curl command ..." --unattended
    

    Note the missing "" in my command before the --unattended flag.

    Once I added this, the Oh My Zsh installation didn't cause the bash script to exit early.