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
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.
-
-
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.Trashesehthumbs.dbThumbs.dbdesktop.ini# Build/dependency directoriesnode_modulesvenv~/.zprofile # Homebrew# macOS Intel x86_64eval "$(/usr/local/bin/brew shellenv)"# macOS Apple silicon arm64eval "$(/opt/homebrew/bin/brew shellenv)"~/.zshrc # Pluginssource $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zshsource $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh# nvmexport 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 completionsfpath=($HOME/.docker/completions $fpath)# pipxexport PATH="$HOME/.local/bin:$PATH"# pnpmexport PNPM_HOME="$HOME/Library/pnpm"case ":$PATH:" in*":$PNPM_HOME:"*) ;;*) export PATH="$PNPM_HOME:$PATH" ;;esac# pnpm end# Java & Android Studio environment variablesexport 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# 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 log# Shawtysalias hg='history | grep' # Search historyalias rg='grep -rHn' # Recursive, display filename and line number -
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.
-