Zend certified PHP/Magento developer

Script to install Anaconda and update conda

I want to write a shell script (zsh) that does the following:

  1. Installs Anaconda via Homebrew.
  2. Adds conda to PATH in .zshrc.
  3. Updates conda base environment.

I have come up with the following solution:

# Installing Anaconda
if [ ! -d /opt/homebrew/Caskroom/anaconda ]; then brew install --cask anaconda; fi

# This adds conda to your PATH in .zshrc and makes sure that you can now use conda and activate conda environments
/opt/homebrew/anaconda3/bin/conda init zsh

# Sourcing zshrc
exec zsh

# Update conda base environment
conda update -n base -c defaults conda

The problem is, that exec zsh replaces the current shell, so the conda update does not happen.

Is there a better solution to the problem?