How to Set Up a Mac for Development
I usually do a fresh install of macOS on my MacBooks and Hackintosh if they ever run sluggish after a major update. Most times, I have to hurdle through multiple tutorials to get my development tools running, so I thought I would put together a guide that I can reference to whenever I need to, which may also help out others who are in the same boat.
Homebrew
The very first thing that I install on my Mac is the Homebrew package manager, which is very popularly used to install almost anything from the CLI.
Just copy-paste this in the Terminal:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Oh My ZSH
I use the regular Terminal app instead of iTerm or any other popular alternative because with Oh My ZSH, I think it does most of what I need it to, plus it also looks great.
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Node Version Manager (NVM)
I do not install Node using Homebrew but rather using NVM. It lets you install and use different versions of Node depending on your requirements and also takes care of lots of complex permission issues.
To install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Verify your installation by entering this in the Terminal and it should return "nvm":
command -v nvm
Then, install Node by entering the following command:
nvm install node
Go to `~/.zshrc` and comment out the following lines:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
And add this:
alias startnvm=". $HOME/.nvm/nvm.sh; . $HOME/.nvm/bash_completion"
There is a reason I do this. Normally, NVM starts whenever you open the Terminal, which takes a a couple seconds for Terminal to load. With those three lines commented out, NVM will no longer load when the Terminal starts, but rather can be started by entering the command `startnvm` on demand.
Installing Apps
A lot of day to day apps can be installed using Homebrew. Here are the command I use:
brew install git yarn && brew install --cask sublime-text docker slack spotify postgres postman
Conclusion
This is basically what I do when I set up a new Mac or do a fresh install. Hope this helps!