Automating setup of a new Macbook - for my future self

Posted

Hello future me! If you're reading this, it means you've got a shiny new MacBook and you're ready to set it up.

Sweet!

I bet you don't remember how we did that last time, do you?

Don't worry, I got you.

In 2024, you found this great Medium article by Daria Sova from 2020. You updated the things that had changed in the last few years (like the command to install casks), and tweaked it for the apps you need on a new machine.

The plan

The shell script you're going to use is written in bash. It automates the process of installing Xcode CLI, Homebrew, your go-to packages and cask apps, and setting zsh as the default shell.

It was also supposed to enable tap-to-click for your trackpad, just how you like it, but something changed in newer versions of macOS and the old methods no longer work. Booo, sad face.

Create the shell script file

Create a new shell script in the command line by entering touch desktop/setup-script.sh

Open the file with the command nano desktop/setup-script.sh

Copy and paste the below code into your new shell script file.

desktop/setup-script.sh

#!/usr/bin/env bash
# Setup script for setting up a new macos machine

# function to print arguments in italic bold
bold_echo() {
    echo "\033[1;3m$*\033[0m"
}

bold_echo "Starting MacBook setup... ๐Ÿ"

# install xcode CLI which is required for Homebrew
xcode-select --install

# Check for Homebrew to be present, install if it's missing
if test ! $(which brew); then
    bold_echo "๐Ÿบ Installing homebrew..."
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

# Update Homebrew recipes if already installed
brew update

PACKAGES=(
    node
    fnm
    git
    zsh
)

bold_echo "๐Ÿ“ฆ Installing packages..."
brew install ${PACKAGES[@]} 


CASKS=(
    adobe-acrobat-reader
    slack
    visual-studio-code
    firefox
    google-chrome
    1password
    miro
)

bold_echo "๐Ÿ“ฆ Installing cask apps..."
brew install --cask ${CASKS[@]}


# set zsh as the default shell
bold_echo "๐Ÿ”„ Switching zsh as the default shell..."
chsh -s $(which zsh)
 
bold_echo "๐Ÿงน Cleaning up...."
brew cleanup

echo "โœ… Macbook setup successful! ๐Ÿ’ช"

Run the script

Open your terminal and cd to the desktop folder where your file is located.

Enter the command sh setup-script.sh.

This will start the process, and you'll need to enter your password several times during the installation process to give permission for specific apps.

That's it!

Your MacBook should now be set up with all your must-have standard apps.

Happy coding!

Jess Budd headshot

Jess is a senior software engineer and web accessibility nerd. When sheโ€™s not writing, speaking or tweeting about tech, youโ€™ll find her putting together lego or going on walks with her doggo.