Skip to content

macOS

Getting started

A brief guide for setting up macOS with essential developer tools, including Xcode command line tools, nvm, pnpm and Homebrew. Follow step-by-step instructions to install, configure and update your development environment efficiently.

References


  1. Xcode command line tools

    Terminal window
    xcode-select --install
  2. nvm

    Terminal window
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
  3. pnpm

    Terminal window
    curl -fsSL https://get.pnpm.io/install.sh | sh -
  4. Download apps


  5. Homebrew

    Install

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

    Add packages

    Terminal window
    brew install ffmpeg jq bat gh pipx zsh-autosuggestions zsh-syntax-highlighting
    • ffmpeg: A complete, cross-platform solution to record, convert and stream audio and video.

    • jq: A lightweight and powerful command-line JSON processor for parsing, filtering and transforming JSON data.

    • bat: a cat clone with syntax highlighting, Git integration and other useful features.

    • gh: official GitHub CLI tool for managing repositories, pull requests, issues and more from the terminal.

    • pipx: tool to install and run Python applications in isolated environments, keeping them separate from system-wide Python packages.

    • zsh-autosuggestions: zsh plugin that provides command-line suggestions based on history and completions.

    • zsh-syntax-highlighting: zsh plugin that adds syntax highlighting to the terminal, improving readability and reducing mistakes.

  6. Update git and shell configs

    ~/.gitconfig
    [init]
    defaultBranch = main
    [user]
    name = # First Last
    [core]
    excludesfile = ~/.gitignore
    # Set postBuffer to 10MB
    [http]
    postBuffer = 10485760
    ~/.gitignore
    # OS files
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    ehthumbs.db
    Thumbs.db
    desktop.ini
    # Build/dependency directories
    node_modules
    venv
    ~/.zprofile
    # Homebrew
    # macOS Intel x86_64
    eval "$(/usr/local/bin/brew shellenv)"
    # macOS Apple silicon arm64
    eval "$(/opt/homebrew/bin/brew shellenv)"
    ~/.zshrc
    # Plugins
    source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
    # nvm
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf "%s" "${HOME}/.nvm" || printf "%s" "${XDG_CONFIG_HOME}/nvm")"
    # Lazy load
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
    # Docker completions
    fpath=($HOME/.docker/completions $fpath)
    # pipx
    export PATH="$HOME/.local/bin:$PATH"
    # pnpm
    export PNPM_HOME="$HOME/Library/pnpm"
    case ":$PATH:" in
    *":$PNPM_HOME:"*) ;;
    *) export PATH="$PNPM_HOME:$PATH" ;;
    esac
    # pnpm end
    # Java & Android Studio environment variables
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
    export ANDROID_HOME=$HOME/Library/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/emulator
    export PATH=$PATH:$ANDROID_HOME/platform-tools
    # Opinionated defaults
    alias ls='ls -A' # List all entries except . and ..
    alias grep='grep --color=auto' # Shows matches in color
    alias rm='rm -i' # Always prompt before removing files
    alias mkdir='mkdir -p' # Automatically create parent directories as needed
    alias cat='bat' # Use bat for syntax highlighting if installed
    # Traversing
    alias ..='cd ..' # Go up one directory
    alias ...='cd ../../../' # Go up three directories
    alias ....='cd ../../../../' # Go up four directories
    alias ~="cd ~" # Go to home directory
    # Git
    alias gs='git status' # Quick git status
    alias ga='git add' # Stage files for commit
    alias gc='git commit' # Commit staged changes
    alias gp='git push' # Push commits to a remote repository
    alias gd='git diff' # Show unstaged differences since last commit
    alias glog='git log --oneline --graph --decorate' # Pretty git log
    # Shawtys
    alias hg='history | grep' # Search history
    alias rg='grep -rHn' # Recursive, display filename and line number
  7. Compile shell

    Terminal window
    exec zsh && zcompile ~/.zshrc && zcompile ~/.zprofile
    • exec zsh fully restarts the shell session and clears any temporary shell variables or functions.

    • zcompile precompiles .zshrc and .zprofile into a binary format (.zshrc.zwc and .zprofile.zwc.

    • When zsh starts, it loads the .zwc files instead of parsing the original files, reducing startup time.