How to set up your new MacBook for coding

So you‘ve got a shiny new MacBook and you‘re ready to start coding up a storm. But before you dive in, it‘s worth taking some time to set up your development environment for maximum productivity and minimum frustration. Having the right tools and configurations can make a huge difference in your speed and efficiency as a developer.

As a full-stack developer who has set up many MacBooks over the years, I‘ve learned a lot about what works well and what doesn‘t. In this guide, I‘ll share my recommendations for must-have applications, configurations, and productivity hacks to transform your stock MacBook into a coding powerhouse.

We‘ll cover:

  • Upgrading your terminal
  • Streamlining Git workflows
  • Installing essential packages and applications
  • Choosing and customizing an IDE
  • Setting up virtualization and containers
  • Automating your configurations with dotfiles

By the end of this guide, your MacBook will be primed and ready for even the most demanding development projects. Let‘s get started!

Upgrading your terminal

If you spend a lot of time in the command line, the default Terminal.app is honestly a bit lackluster. Luckily there are some excellent alternatives that add a ton of useful features to supercharge your terminal experience.

My personal favorite is iTerm2. Some of the key features that make it indispensable for me:

  • Search – quickly find commands from your history
  • Autocomplete – intelligently suggest commands and file paths as you type
  • Paste history – easily access recently copied text
  • Split panes – divide the terminal into multiple sessions in a single window

But iTerm2 is just the beginning. To really max out your command line productivity, I highly recommend installing oh-my-zsh, a framework for managing your zsh configuration.

In addition to setting options and adding useful functions, oh-my-zsh makes it easy to customize your prompt. Here‘s what mine looks like:

oh-my-zsh terminal prompt

The prompt shows:

  • Current directory
  • Git branch and status (clean vs dirty)
  • Battery level
  • Last command exit code (green checkmark for success, red X for failure)
  • Timestamp

With oh-my-zsh, you can easily enable all sorts of plugins to add tab completion, aliases, and integrations with other tools. Some of my must-haves are:

Here are a few of the aliases I have in my .zshrc to save keystrokes on frequently used commands:

alias gs="git status" 
alias gcm="git commit -m"
alias gpo="git push origin"
alias glo="git log --oneline"

alias rst="rails server --binding=0.0.0.0" 
alias cop="rubocop"
alias rsp="rspec"

Setting up zsh this way has made me enjoy using the terminal so much more and saves me countless hours over the long run.

Streamlining Git workflows

Source control is an essential part of any developer‘s toolkit, and Git is by far the most popular choice these days. While the built-in Git commands are very powerful, they can be verbose and hard to remember.

Luckily, Git allows you to define your own aliases to shorten frequently used commands. Here are a few I have in my ~/.gitconfig:

[alias]
  co = checkout
  cob = checkout -b 
  cm = commit -m
  ca = commit -am
  rb = rebase  
  rbi = rebase -i
  rbc = rebase --continue
  st = status
  to = push origin 
  logs = log --graph --oneline --decorate --color

Now instead of typing git checkout -b new-feature, I can just do git cob new-feature. The logs alias is especially nice for a concise, visual history of the repo.

Another Git tip is to set up a global .gitignore file to automatically exclude common unversioned files from all your repos. Here‘s what I have in ~/.gitignore_global:

*~
.DS_Store
.idea
*.iml
.vscode
.ruby-version
.byebug_history
.env
/vendor/bundle
/log/*
/tmp/*
node_modules/

With this, I never have to worry about accidentally committing editor configs, build artifacts, or other generated files.

Installing essential packages

Now that your terminal is tricked out and Git is streamlined, it‘s time to install some essential packages. On a Mac, the easiest way to do this is with the Homebrew package manager.

To install Homebrew, just run this command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once it‘s set up, you can install packages with the brew command, e.g. brew install node to install Node.js.

In addition to command line packages, Homebrew can install desktop applications with Cask. This is often easier and more reliable than downloading from vendor sites. For example, to install Google Chrome:

brew install --cask google-chrome

You can also keep your Mac App Store purchases up to date from the command line with mas-cli:

brew install mas
mas upgrade

Here are some of the packages and applications I use for development:

  • git
  • gh (GitHub CLI)
  • node
  • yarn
  • python
  • ruby
  • go
  • docker
  • postgresql
  • redis
  • visual-studio-code
  • sublime-text
  • iterm2
  • dash (offline API docs)
  • postman
  • tunnelblick (VPN)
  • spectacle (window management)

Having a standard set of tools installed from the get-go can make setting up new projects a lot smoother. Homebrew makes it easy to automate this across multiple machines as well.

Choosing an IDE

One of the most important choices you‘ll make as a developer is your code editor or IDE. This is an area of fierce debate and personal preferences, and there‘s no one "right" answer. That said, here are a few of the most popular cross-platform choices:

  • VS Code – My current favorite for its vast library of extensions, speed, and ease of use
  • WebStorm – Very powerful and feature-rich, especially for larger JavaScript projects
  • Sublime Text – Tried and true, extremely fast and customizable

Whichever you choose, take some time to learn its keyboard shortcuts, installed recommended plugins, and tweak its settings for your coding style. Having a well-honed editor setup can make you significantly more efficient.

Setting up local development

As a full-stack developer, you‘ll often need to run code in different environments locally to test before pushing to production. The traditional way to do this is to install runtimes like Node, Python, Ruby, etc. directly on your machine using a version manager like nvm, pyenv, or rvm.

However, in my experience it‘s often easier to use containers and virtual machines to keep the development environment isolated from your host operating system. My go-to tools for this are:

  • Docker – for running apps and services in lightweight containers. The docker-compose tool makes defining multi-service environments very straightfoward.
  • Vagrant – for spinning up headless virtual machines. Vagrant makes it easy to distribute pre-configured VMs for development that closely mirror production.

By combining these tools with configuration files checked into source control, you can ensure all developers on a project are using the exact same environment.

Automating setup with dotfiles

Once you have your favorite tools and configurations in place, it‘s a good idea to save them in a dotfiles repo. This allows you to quickly bootstrap a new computer or share your setup with others.

Some key files to include:

  • .zshrc or .bashrc
  • .gitconfig
  • .gitignore_global
  • .vimrc or editor configs
  • Homebrew Brewfile
  • .macos file for setting system preferences

I keep my dotfiles on GitHub with a master install script that sets everything up from scratch on a new machine. It‘s a huge timesaver!

Conclusion

Setting up a new development machine is a very personal process that evolves over time as you learn new tools and tricks. The most important thing is to find a workflow that helps you be productive and reduces cognitive overhead.

Hopefully this guide has given you some ideas for how to configure your own MacBook for coding bliss. The key things to remember are:

  1. Upgrade your terminal with iTerm2 + oh-my-zsh
  2. Streamline common Git workflows with aliases and configs
  3. Install essential packages and applications with Homebrew
  4. Choose and learn an IDE/editor that supercharges your productivity
  5. Use containers and VMs to isolate development environments
  6. Automate your setup with dotfiles and scripts

Now go forth and happy coding!

What are some of your must-have tools and configurations for development? Let me know on Twitter @joshukraine.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *