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 = huffmanks
    email = huffmanks2@gmail.com
    [core]
    excludesfile = ~/.gitignore
    # Set postBuffer to 10MB
    [http]
    postBuffer = 10485760
    ~/.gitignore
    # ==============================
    # OS / System Files
    # ==============================
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    desktop.ini
    ehthumbs.db
    Thumbs.db
    # ==============================
    # macOS Metadata
    # ==============================
    .AppleDouble
    .LSOverride
    .fseventsd
    .VolumeIcon.icns
    # ==============================
    # Linux / Unix Metadata
    # ==============================
    .nfs*
    lost+found/
    # ==============================
    # Build / Dependency Directories
    # ==============================
    .astro
    .next
    .output
    .output_static
    .vercel
    build/
    dist/
    node_modules/
    out/
    output/
    tmp/
    venv/
    __pycache__/
    # ==============================
    # Environment & Config Files
    # ==============================
    .env
    .env.*
    .env.development
    .env.local
    .env.production
    .env.test
    .envrc
    !example*.env*
    !.env*example*
    # ==============================
    # Logs & Debug
    # ==============================
    *.log
    npm-debug.log*
    yarn-debug.log*
    yarn-error.log*
    pnpm-debug.log*
    .pnpm-debug.log*
    *.pid
    *.seed
    *.pid.lock
    # ==============================
    # Python Cache / Virtualenv
    # ==============================
    *.py[cod]
    *.pyo
    *.pyd
    __pycache__/
    .python-version
    # ==============================
    # IDE / Editor Settings
    # ==============================
    *.swp
    *.swo
    *.swn
    *.bak
    *.tmp
    # ==============================
    # Test Coverage / Reports
    # ==============================
    coverage/
    .nyc_output/
    pytest_cache/
    junit.xml
    # ==============================
    # Miscellaneous
    # ==============================
    *.tgz
    *.tar.gz
    *.zip
    *.7z
    ~/.zprofile
    # Homebrew
    # macOS Intel x86_64
    eval "$(/usr/local/bin/brew shellenv)"
    # macOS Apple silicon arm64
    eval "$(/opt/homebrew/bin/brew shellenv)"
    ~/.zshrc
    # ==============================
    # macOS .zshrc
    # ==============================
    # ----- NVM -----
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf "%s" "${HOME}/.nvm" || printf "%s" "${XDG_CONFIG_HOME}/nvm")"
    # Remove --no-use to disable lazy load
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
    # ----- Docker -----
    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
    # ----- Java & Android Studio -----
    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
    # ----- Aliases -----
    # 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
    alias gfu='git fetch origin && git reset --hard origin/main && git clean -fd' # Force update: reset local branch and files to match remote
    alias gsu='git submodule update --remote --merge' # Update submodules to latest remote commit with merge
    # Shawtys
    alias hg='history | grep' # Search history
    alias rg='grep -rHn' # Recursive, display filename and line number
    # ----- Plugins -----
    # --- zsh-autosuggestions ---
    source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
    # --- zsh-syntax-highlighting ---
    # Must be last
    source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  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.