macOS Development Environment Setup

11/01/2022·2 min read

macOSDevelopmentProductivity

Setting up a new Mac can be a detailed process. This guide provides a streamlined checklist for configuring a clean, efficient, and developer-friendly macOS environment.

System Preferences

A few initial tweaks to System Preferences can significantly improve the user experience.

  • Trackpad:
    • Set tracking speed to a higher sensitivity (e.g., MAX - 1).
    • Enable "Tap to click" and "Three-finger drag".
    • Enable "Look up & data detectors" with a three-finger tap.
  • Date & Time:
    • Set to your correct region.
    • Use 24-hour time format and Celsius for temperature.
  • Privacy & Security:
    • Consider changing your computer's name to something generic to avoid broadcasting your personal name on networks.
  • Keyboard:
    • Disable "Smart quotes" to avoid issues when writing code.

Terminal & Shell

A powerful terminal setup is essential for any developer. This setup uses zsh with Oh My Zsh.

  1. Install Fonts: For better readability, install a developer-friendly font like SF Mono.

  2. Install Oh My Zsh: A framework for managing your zsh configuration.

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    
  3. Configure ~/.zshrc:

    • Plugins: Enable useful plugins to enhance your shell.

      plugins=(
          git
          brew
          macos
          zsh-syntax-highlighting
          zsh-autosuggestions
          timer
      )
      
  4. Recommended Tools:

    • eza: A modern replacement for ls, built on exa.
    • bat: A cat clone with syntax highlighting.
    • fzf: A command-line fuzzy finder.
    • ripgrep: A fast, recursive search tool.
    • zoxide: A smarter cd command.
    • fnm: A fast Node.js version manager.
    • Explore more at modern-unix

fzf

export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type d --strip-cwd-prefix --hidden --follow --exclude .git"

# Preview file content using bat (https://github.com/sharkdp/bat)
export FZF_CTRL_T_OPTS="
  --preview 'bat -n --color=always {}'
  --bind 'ctrl-/:change-preview-window(down|hidden|)'"

# Print tree structure in the preview window
export FZF_ALT_C_OPTS="--preview 'eza --tree --colour=always {}'"

Development Tools

  1. Install Homebrew: The missing package manager for macOS.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Configure Git: Set your identity for commits.

    # Set your commit email address
    git config --global user.name "Your Name"
    git config --global user.email "your-email@example.com"
    

    Refer to GitHub's documentation for managing commit email addresses.

  3. Configure SSH: Use a ~/.ssh/config file to manage multiple SSH keys and hosts.

    Host github.com
        AddKeysToAgent yes
        UseKeychain yes
        IdentityFile ~/.ssh/id_ed25519
    
    Host work-server
        HostName server.work.com
        User admin
        IdentityFile ~/.ssh/id_rsa_work
    

    If you did not add a passphrase to your key, omit the UseKeychain line.

Essential Applications

Install these applications via Homebrew Cask or direct download for a productive workflow.

  • Visual Studio Code: A versatile and popular code editor.
  • iStat Menus: A system monitor for your menu bar.
  • Swish: A window manager with trackpad gestures.
  • Firefox or Chrome: Choose your preferred browser.
  • iTerm2: A powerful terminal emulator.
  • Zed: A high-performance, multiplayer code editor built in Rust.
  • Ghostty: A fast, feature-rich, and native terminal emulator.