macOS Terminal and Shell Productivity for DevOps Engineers
Level up your macOS terminal: Homebrew, Oh My Zsh, SSH key management, PATH config, iTerm2 tricks, and battle-tested DevOps aliases.
The macOS terminal is a first-class DevOps workstation — especially when you layer in Homebrew, a well-tuned Zsh config, and a handful of macOS-native commands that simply don’t exist on Linux. This page collects the patterns and one-liners that make day-to-day infrastructure work faster and less error-prone.
The installer guides you through Xcode Command Line Tools if they are missing. On Apple Silicon, Homebrew lands in /opt/homebrew/ — remember to add it to your PATH (see PATH Management below).
macOS has shipped Zsh as the default shell since Catalina. Oh My Zsh turbo-charges it with plugin management, themes, and hundreds of community shortcuts.
1
Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
2
Pick a theme
Open ~/.zshrc and set your preferred theme. A reliable, information-dense
choice for DevOps work:
ZSH_THEME="agnoster" # shows git branch + exit code in prompt
For a faster, no-font-dependency option:
ZSH_THEME="robbyrussell"
3
Enable useful plugins
plugins=(git z docker kubectl terraform aws brew macos)
Add this line (or edit the existing plugins=(...) block) in ~/.zshrc, then reload:
source ~/.zshrc
The z plugin tracks your most-visited directories and lets you jump to them
with z <partial-name> instead of typing full paths. It pays for itself
within the first hour.
These commands either don’t exist on Linux or behave differently — they’re worth knowing because they integrate tightly with macOS internals.
open — launch anything from the terminal
open is the terminal equivalent of double-clicking in Finder.
open . # Open current directory in Finderopen ~/Downloads # Open a folderopen -a "Visual Studio Code" . # Open current dir in a specific appopen https://example.com # Open URL in default browseropen -R ~/some/file.txt # Reveal file in Finder (don't open it)
pbcopy / pbpaste — clipboard integration
Pipe anything into the system clipboard or back out again — invaluable for sharing command output without mouse gymnastics.
cat ~/.ssh/id_ed25519.pub | pbcopy # Copy SSH public key to clipboardpbpaste > ~/Desktop/snippet.txt # Dump clipboard contents to a fileecho "hello" | pbcopy && pbpaste # Quick round-trip test
say — text-to-speech notifications
Useful for alerting you when a long-running script finishes without requiring you to watch the terminal.
terraform apply && say "Terraform apply complete" || say "Terraform failed"sleep 3600 && say "One hour timer done"
caffeinate — prevent sleep during long jobs
Stops macOS from sleeping while a script runs. Pairs perfectly with large deploys or overnight syncs.
caffeinate -i make build # Keep system awake for the durationcaffeinate -t 7200 # Stay awake for exactly 2 hourscaffeinate -s ./backup-script.sh # Prevent system sleep (not display sleep)
networksetup — manage network from the CLI
Control Wi-Fi, DNS, and proxies without touching System Settings — great for scripted environment switching.
networksetup -listallnetworkservices # List interfacesnetworksetup -getdnsservers Wi-Fi # Show current DNS serversnetworksetup -setdnsservers Wi-Fi 1.1.1.1 8.8.8.8 # Set custom DNSnetworksetup -setairportpower en0 off # Turn Wi-Fi offnetworksetup -setairportpower en0 on # Turn Wi-Fi on
diskutil — disk and volume management
diskutil list # List all disks and partitionsdiskutil info /dev/disk0 # Detailed info on a diskdiskutil eraseDisk APFS MyDisk /dev/disk2 # Format a disk (DESTRUCTIVE)diskutil unmountDisk /dev/disk2 # Unmount all volumes on a disk
diskutil eraseDisk is irreversible. Always double-check the device
identifier with diskutil list before running destructive commands.
defaults — read and write macOS preferences
Every macOS app stores its settings in a plist database that defaults exposes as a CLI.
# Show hidden files in Finderdefaults write com.apple.finder AppleShowAllFiles true && killall Finder# Disable the Gatekeeper quarantine warning (use carefully)defaults write com.apple.LaunchServices LSQuarantine -bool false# Speed up Dock animationdefaults write com.apple.dock autohide-delay -float 0 && killall Dock# Show full path in Finder title bardefaults write com.apple.finder _FXShowPosixPathInTitle -bool true && killall Finder# Read a value backdefaults read com.apple.dock autohide-delay
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@remote-host# or, if ssh-copy-id is unavailable:cat ~/.ssh/id_ed25519.pub | pbcopy # then paste into ~/.ssh/authorized_keys
5
List keys currently loaded in the agent
ssh-add -l
Use separate key pairs for different contexts — personal GitHub, work GitLab,
cloud jump hosts — and route them with Host blocks in ~/.ssh/config.
This limits blast radius if a key is ever compromised.
On Apple Silicon, Homebrew lives at /opt/homebrew/bin, not /usr/local/bin. Managing PATH cleanly avoids subtle version conflicts between system tools and Homebrew-installed ones.
Use ~/.zprofile for environment variables (runs at login) and ~/.zshrc
for interactive settings like aliases and plugins (runs per shell session).
Avoid duplicating PATH exports across both files.
~/.zprofile — canonical place for PATH on Apple Silicon
# Homebrew (Apple Silicon)eval "$(/opt/homebrew/bin/brew shellenv)"# Homebrew (Intel fallback)# eval "$(/usr/local/bin/brew shellenv)"# Language version managersexport PATH="$HOME/.rbenv/shims:$PATH" # Rubyexport PATH="$HOME/.pyenv/shims:$PATH" # Pythonexport PATH="$HOME/go/bin:$PATH" # Go binariesexport PATH="$HOME/.cargo/bin:$PATH" # Rust# Local scripts — highest priorityexport PATH="$HOME/.local/bin:$PATH"
Check the effective PATH without opening a new shell:
echo $PATH | tr ':' '\n' # One entry per line — much easier to read