← cd ~/posts
Jul 4, 2026 #macos #zsh

macOS Terminal & Zsh

# macos essentials

open . open the current directory in Finder (open any file with its default app)
pbcopy < file.txt copy file contents to the clipboard
pbpaste > file.txt paste clipboard contents to a file
brew install wget install packages with Homebrew, the macOS package manager
mdfind "query" Spotlight search from the command line
sw_vers show macOS version information
caffeinate prevent the Mac from sleeping while a command runs
screencapture -i shot.png take an interactive screenshot
defaults write com.apple.finder AppleShowAllFiles true read/write app preferences from the shell
diskutil list list disks and partitions (the macOS fdisk)
say "build finished" speak text aloud — handy at the end of long commands

# zsh features

chsh -s /bin/zsh make zsh your login shell (default since macOS Catalina)
setopt AUTO_CD type a directory name alone to cd into it
ls **/*.txt recursive globbing — matches at any depth, no find needed
alias -g G="| grep" global aliases expand anywhere in the line: ps aux G ssh
pushd /etc push directory onto the stack; popd returns; dirs lists the stack
autoload -Uz compinit && compinit enable the powerful zsh tab-completion system
setopt SHARE_HISTORY share command history live across all open terminals
autoload zmv && zmv "(*).txt" "$1.md" batch-rename files with patterns
← back to all posts