How to Setup a New Computer (Again)

I have set up a new computer at least 15 times and each time it's been like I'm doing it from scratch. But I just got a new computer and it's high time to fix this problem. I'll show you how I made this process super easy.

Checklist

Here are the goals for this project.

  1. Be able to do everything below by just running one command
  2. Have the script be re-runnable with no side effects
  3. Install Homebrew and associated apps
  4. Install Oh My Zsh
  5. Configure git
  6. Configure GitHub
  7. Configure Mac settings
  8. Install important scripts

If you just want to see the final result, check out the dotfiles repo.

Key Files

Breaking the files up will allow for better organization and easier maintenance.

  • curl-entry.sh will be the entry point when calling via curl which will enable it to be one command to get it going
  • install.sh will be the main script that will delegate to other scripts as needed
  • .zshrc will contain my standard zsh config
  • Brewfile will contain the list of apps to install with Homebrew
  • system-preferences.sh will contain all the Mac OSX settings I always set, like tap to click, locking desktop positions, etc.
  • .gitconfig will contain my standard git config

Because there's a single entry point, it's super easy to run the script.

curl https://raw.githubusercontent.com/rgpass/dotfiles/main/curl-entry.sh | bash

Flow

Running the above command will do:

  1. curl the entry point file and pipe to bash
  2. Clone into a new directory and run the install.sh script
  3. Configure sudo to only need to be entered once
  4. Make all the directories I normally make
  5. Install z (frecent algorithm for jumping directories)
  6. Install Oh My Zsh
  7. Create symlink for .zshrc
  8. Install or update Homebrew
  9. Install all the apps in the Brewfile
  10. Configure the Mac settings
  11. Configure git and GitHub
  12. Exit all apps that would need to be restarted

After it's all done, the computer will be ready to go.

Key Findings

  • Brewfile's are super helpful and can be generated with brew bundle dump. This creates a full dump, but you probably don't want all of them
  • Also, you don't really need to keep dependencies versioned, so you can remove Brewfile.lock.json