MacBook Pro setup for Development

Matt Palmerlee
5 min readJan 29, 2024

--

MacBook Visual Studio Code

I just recently setup a MacBook Pro as my new development machine and even though there are plenty of resources out there on what to install and settings to tweak, everyone has their own preferences and I figured this post may help the future me setup the next MacBook with similar settings.

Homebrew

Your OSX package manage should be the first thing you install since almost everything else you’ll need can be installed via brew.

Once installed, make sure you update:

brew update

Install GUI applications as desired via brew:

brew install --cask \
google-chrome \
iterm2 \
visual-studio-code \
docker \
rectangle \
slack \
vlc

Terminal setup: iTerm2, Oh my zsh and starship

Now that we have our package manager setup we want to get out of the default OSX terminal and use and configure iTerm to our liking.

First we can install iTerm2 via brew:

brew install --cask iterm2

Then install oh my zsh for a superior terminal experience.

Once installed make sure it is up to date:

omz update

Install Starship as the terminal theme.

brew install starship

Then make it the default theme:

echo 'eval "$(starship init zsh)"' >> ~/.zshrc

Install and use the Hack Nerd Font in iTerm2:

brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font

In iTerm2 navigate to Preferences -> Profile -> Text -> Font: font-hack-nerd-font.

Choose the Hack Nerd Font in iTerm2

After changes to your zsh profile, don’t forget to force a reload:

source ~/.zshrc

Install Oh My Zsh Plugins:

git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Snippet of my ~/.zshrc file with activated plugins:

# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
)

fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src

source $ZSH/oh-my-zsh.sh
# User configuration

Install Node via nvm

The Node Version Manager (nvm) is a crucial tool for installing and switching between different versions of node.

brew install nvm

Then make sure it is available in the path:

echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.zshrc

Then install the latest lts version of node:

nvm install --lts

Install a Python version manager

To install and switch between multiple versions of Python on the system I’m using pyenv. First let’s install with brew:

brew install pyenv

Finish the installation of pyenv by running:

echo 'eval "$(pyenv init -)"' >> ~/.zshrc

source ~/.zshrc

Next we can start installing python versions:

pyenv install 3.9.6
pyenv global 3.9.6

pyenv install 3.11.6
pyenv install 3.12.1

Install direnv

Using virtualenv is crucial for python projects, direnv allows us to automate running a script to activate a virtual environment anytime it finds a .envrc file in the current directory or a parent directory.

brew install direnv

Next we need to add the hook to direnv in our .zshrc file:

echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc

source ~/.zshrc

Then in our python project directory (e.g. ~/workspace/python-example) we will add a new .envrc file:

touch .envrc

Then you need to allow this directory for direnv:

direnv allow

Finally add the following to your .envrc file:

# check if python version is set in current dir
if [ -f ".python-version" ] ; then
if [ ! -d ".venv" ] ; then
echo "Installing virtualenv for $(python -V)"
# if we didn't install `py2venv` for python 2.x, we would need to use
# `virtualenv`, which you would have to install separately.
python -m venv .venv
fi
echo "Activating $(python -V) virtualenv"
source .venv/bin/activate
fi
# announce python version and show the path of the current python in ${PATH}
echo "Virtualenv has been activated for $(python -V)"
echo "$(which python)"

If everything went well we’ll see a message like this:

Virtualenv has been activated for Python 3.11.6

Update Mac OSX settings

Finally there are some operating system settings I like to tweak in OSX for developer joy:

Update Finder settings:

# show hidden files
defaults write com.apple.finder AppleShowAllFiles YES

# show path bar
defaults write com.apple.finder ShowPathbar -bool true

# show status bar
defaults write com.apple.finder ShowStatusBar -bool true

One default behavior I could never get used to in OSX is the home and end keys going to the top and end of the file respectively. To change the behavior to mimic windows where home and end go to the start and end of the line instead we can update the keybindings according to Damien Guard’s post: Make Home & End keys behave like Windows on Mac OS X like so:

mkdir ~/Library/KeyBindings

cat <<EOF >> ~/Library/KeyBindings/DefaultKeyBinding.dict
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
EOF

This change does require a system restart to take effect. Once that’s done most of the tedious steps to getting up and running on a new MacBook Pro are done. Happy Coding!

--

--