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
- Xcode command line tools
- nvm
- pnpm
- Homebrew
- bat
- ffmpeg
- gh
- jq
- pipx
- zsh-autosuggestions
- zsh-syntax-highlighting
-
Xcode command line tools
Terminal window xcode-select --install -
nvm
Terminal window curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash -
pnpm
Terminal window curl -fsSL https://get.pnpm.io/install.sh | sh - -
Download apps
-
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
catclone 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.
-
-
Update git and shell configs
~/.gitconfig [init]defaultBranch = main[user]name = huffmanksemail = huffmanks2@gmail.com[core]excludesfile = ~/.gitignore# Set postBuffer to 10MB[http]postBuffer = 10485760~/.gitignore # ==============================# OS / System Files# ==============================.DS_Store.DS_Store?._*.Spotlight-V100.Trashesdesktop.iniehthumbs.dbThumbs.db# ==============================# macOS Metadata# ==============================.AppleDouble.LSOverride.fseventsd.VolumeIcon.icns# ==============================# Linux / Unix Metadata# ==============================.nfs*lost+found/# ==============================# Build / Dependency Directories# ==============================.astro.next.output.output_static.vercelbuild/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# ==============================*.lognpm-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_64eval "$(/usr/local/bin/brew shellenv)"# macOS Apple silicon arm64eval "$(/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/Homeexport ANDROID_HOME=$HOME/Library/Android/sdkexport PATH=$PATH:$ANDROID_HOME/emulatorexport PATH=$PATH:$ANDROID_HOME/platform-tools# ----- Aliases -----# Opinionated defaultsalias ls='ls -A' # List all entries except . and ..alias grep='grep --color=auto' # Shows matches in coloralias rm='rm -i' # Always prompt before removing filesalias mkdir='mkdir -p' # Automatically create parent directories as neededalias cat='bat' # Use bat for syntax highlighting if installed# Traversingalias ..='cd ..' # Go up one directoryalias ...='cd ../../../' # Go up three directoriesalias ....='cd ../../../../' # Go up four directoriesalias ~="cd ~" # Go to home directory# Gitalias gs='git status' # Quick git statusalias ga='git add' # Stage files for commitalias gc='git commit' # Commit staged changesalias gp='git push' # Push commits to a remote repositoryalias gd='git diff' # Show unstaged differences since last commitalias glog='git log --oneline --graph --decorate' # Pretty git logalias gfu='git fetch origin && git reset --hard origin/main && git clean -fd' # Force update: reset local branch and files to match remotealias gsu='git submodule update --remote --merge' # Update submodules to latest remote commit with merge# Shawtysalias hg='history | grep' # Search historyalias 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 lastsource $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -
Compile shell
Terminal window exec zsh && zcompile ~/.zshrc && zcompile ~/.zprofile-
exec zshfully restarts the shell session and clears any temporary shell variables or functions. -
zcompileprecompiles.zshrcand.zprofileinto a binary format (.zshrc.zwcand.zprofile.zwc. -
When zsh starts, it loads the
.zwcfiles instead of parsing the original files, reducing startup time.
-