10 min read · October 2026 · Intermediate

Terminal Productivity Hacks for Mac

The Terminal is the single most under-used productivity tool on macOS. Once you learn a handful of commands, customize your shell, install a few packages through Homebrew, and define a personal library of aliases and scripts, routine tasks that once took five clicks collapse into one keystroke. This guide walks you from the essential daily commands through a tuned zsh setup, a Homebrew-powered toolbox, time-saving aliases and functions, and finally a set of ready-to-use scripts you can drop straight into your ~/bin folder.

Table of Contents

  1. Essential Commands
  2. Customizing Terminal
  3. Homebrew Package Manager
  4. Aliases & Functions
  5. Useful Scripts

1. Essential Commands Every Mac User Should Know

Before you install a single package or write a line of configuration, there is a core set of commands that forms the vocabulary of the shell. These are the verbs you'll type dozens of times a day, and fluency with them is the difference between the Terminal feeling like a chore and feeling like a superpower. Each command below is small on its own, but they compose into fast workflows when you chain them with pipes, redirection, and command substitution.

Think of this section as a working dictionary. Open your Terminal, try each command on a safe directory such as ~/Desktop/sandbox, and watch the output. Reading a command's description tells you what it does; typing it until your fingers remember the flags is what makes it stick. The macOS shell is zsh by default on recent versions and bash on older systems — these commands work identically in both.

Navigation and Inspection

Every session begins with knowing where you are and what's around you. The following four commands handle 90% of day-to-day navigation.

Terminal
pwd

pwd (print working directory) tells you exactly where in the filesystem your shell is sitting. Pair it with ls to see what's in that directory. The -la flags give you a long listing including hidden files, permissions, owners, and sizes, which is the view you'll want most of the time.

Terminal
ls -la

Move around with cd. Typing just cd with no arguments takes you home. cd - jumps back to the previous directory, which is extremely useful when toggling between two project folders.

Terminal
cd ~/Projects/raylaunchmac

Create directories, including nested ones, in a single command with mkdir -p. The -p flag makes any missing parent directories without complaining.

Terminal
mkdir -p ~/Projects/new-site/assets/css

Moving, Copying, and Deleting

The classic trio cp, mv, and rm handle every file operation you can do in Finder, but with the ability to use wildcards and operate on hundreds of files at once. cp -R copies directories recursively, mv renames or relocates, and rm deletes.

Terminal
cp -R ~/Projects/site ~/Projects/site-backup
Terminal
mv draft-article.md published-article.md
Terminal
rm old-draft.md
Warning: rm -rf is irreversible. There is no Trash, no undo, no "are you sure?" dialog. A misplaced space turns rm -rf ~/Downloads/temp into rm -rf ~ /Downloads/temp, which deletes your entire home folder. Always double-check the path, consider ls on it first, and never run rm -rf on a variable path without verifying the variable is non-empty.

Reading, Searching, and Finding

cat dumps a whole file to the screen — perfect for small files. For larger ones, less gives you a scrollable pager (press q to quit). grep is the search workhorse: it filters lines matching a pattern, and with -r it recursively searches entire directory trees. find locates files by name, size, type, and age.

Terminal
cat README.md
Terminal
grep -rn "TODO" ./src
Terminal
find ~/Downloads -name "*.dmg" -mtime +30

The find example above lists every .dmg installer in your Downloads folder older than 30 days — the first step towards reclaiming gigabytes of disk space.

Monitoring and Disk Usage

top shows live CPU and memory usage. On modern Macs, htop (installed via Homebrew) is much nicer. df -h reports filesystem free space in human-readable units, and du -sh * summarizes the size of every item in the current directory.

Terminal
top -o cpu
Terminal
df -h
Terminal
du -sh * | sort -h

macOS-Specific Superpowers

macOS ships several commands that don't exist on Linux and that bridge the shell with the rest of the desktop. open opens any file or folder with its default app — including the current directory in Finder with open ., or a URL in your browser.

Terminal
open .
Terminal
open -a "Visual Studio Code" ~/Projects/raylaunchmac

The clipboard pair pbcopy and pbpaste is pure gold. Pipe anything into pbcopy and it lands on your clipboard, ready to paste into any app. Pipe pbpaste into any command and the current clipboard contents stream in as input.

Terminal
pwd | pbcopy
Terminal
pbpaste | grep -i error
Tip: Every command has a manual page. Type man ls, man grep, or man find to read the full documentation, flags, and examples. Press / to search inside a man page and q to quit. Reading one new man page a week will quietly turn you into a shell power user over a year.

2. Customizing the Terminal and Your Shell

A default Terminal is like a brand-new keyboard with no key caps: functional, but joyless. A tuned shell is the opposite — a tool that fits your hands, shows you useful information at a glance, autocompletes aggressively, and feels fast. On modern macOS, your login shell is zsh, and almost all customization lives in a single file: ~/.zshrc. Edit it, open a new Terminal tab, and your changes are live.

The customization stack has three layers: the shell itself (zsh), a framework like oh-my-zsh that bundles plugins and themes, and the terminal emulator (Terminal.app, iTerm2, Warp, Ghostty, or Wezterm) that renders characters. Changes to the shell are portable across emulators; changes to the emulator affect fonts, colors, and window behavior but not what the shell does.

Install Oh My Zsh

Oh My Zsh is the most popular zsh framework. It gives you themes, hundreds of plugins, and sensible defaults in one install.

Terminal
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

After installation, open ~/.zshrc in your editor:

Terminal
open -a "TextEdit" ~/.zshrc

Pick a Theme

Themes control your prompt — the line that appears before you type each command. A good prompt shows your current directory, git branch, and command exit status without being noisy. Popular choices include agnoster, robbyrussell (the default), and the ultra-fast standalone powerlevel10k.

Terminal
ZSH_THEME="agnoster"

For powerlevel10k, which runs a one-time wizard to style your prompt exactly how you want:

Terminal
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Then set ZSH_THEME="powerlevel10k/powerlevel10k" and open a new Terminal to launch the wizard.

Enable Plugins

Plugins add autocompletion, syntax highlighting, suggestions, and shortcuts. Two must-haves are zsh-autosuggestions (greys out suggestions as you type based on your history) and zsh-syntax-highlighting (colors commands green when valid, red when not). Install them:

Terminal
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Then edit the plugins=(...) line in your ~/.zshrc to enable them:

~/.zshrc
plugins=(git macos brew docker zsh-autosuggestions zsh-syntax-highlighting)

The git plugin alone gives you dozens of handy aliases like gst (git status), gcm (git commit -m), and gpl (git pull). The macos plugin adds helpers like showfiles/hidefiles to toggle hidden files in Finder.

Tune the Prompt and History

Add these lines to the bottom of ~/.zshrc for a more useful shell: a much larger history, sensible history behaviour, and some quality-of-life settings.

~/.zshrc
HISTSIZE=50000 SAVEHIST=50000 setopt HIST_IGNORE_ALL_DUPS setopt HIST_IGNORE_SPACE setopt SHARE_HISTORY setopt AUTO_CD setopt CORRECT

Reload your config without opening a new tab:

Terminal
source ~/.zshrc

Pick a Better Emulator

Terminal.app is fine, but iTerm2 adds split panes, hotkey window, triggers, and much better search. Warp and Ghostty are modern GPU-accelerated alternatives with AI command suggestions and a cleaner UX. All of them are free. Choose whichever matches your taste — your zsh config will follow you.

3. Homebrew — The Missing Package Manager

Homebrew is the de facto standard for installing command-line tools, open-source apps, fonts, and even full GUI applications on macOS. Instead of hunting down installers, dragging DMGs, and manually updating each app, you install everything with a single command and update everything with another. For developers and power users, Homebrew is non-negotiable.

Homebrew installs into /opt/homebrew on Apple Silicon Macs and /usr/local on Intel Macs. It never touches system files, which means you can uninstall it cleanly, and it automatically updates its own package database when you run brew update.

Install Homebrew

Terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After installation, the installer will tell you to run two lines to add Homebrew to your PATH. Follow them exactly, or Homebrew's binaries won't be found. On Apple Silicon this looks like:

Terminal
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc eval "$(/opt/homebrew/bin/brew shellenv)"

Everyday Brew Commands

Install any CLI tool with brew install. For example, grab a modern replacement for cat, a fuzzy finder, and a JSON processor:

Terminal
brew install bat fzf jq htop ripgrep fd eza

Refresh the package database before any install or upgrade — this is cheap and takes a few seconds:

Terminal
brew update

Upgrade every installed package to the latest version:

Terminal
brew upgrade

Remove old versions and free up disk space:

Terminal
brew cleanup -s

Check for a broken install or missing dependency:

Terminal
brew doctor

Casks — Full GUI Apps

Add --cask and Homebrew installs full GUI apps the same way, dropping them into /Applications. This is the fastest way to set up a fresh Mac.

Terminal
brew install --cask iterm2 visual-studio-code raycast rectangle google-chrome

Taps and Bundles

Some packages live outside the main Homebrew repository. A tap is a third-party repository you add with brew tap.

Terminal
brew tap homebrew/cask-fonts brew install --cask font-jetbrains-mono-nerd-font

For reproducible setups across machines, save a Brewfile and reinstall everything with one command on a new Mac:

Terminal
brew bundle dump --file=~/Brewfile --force brew bundle --file=~/Brewfile

4. Aliases and Functions — Make the Shell Yours

An alias is a short name for a longer command. A function is an alias with arguments and logic. Together they let you compress the commands you type most into one or two keystrokes, and they are stored in plain text in ~/.zshrc, so they travel with your dotfiles. The goal isn't to memorise aliases from someone else's list — it's to notice which commands you keep retyping and encode them.

Useful Aliases

Drop these into the bottom of your ~/.zshrc, then run source ~/.zshrc to load them. Many of them replace common commands with safer or richer versions.

~/.zshrc
# listing alias ll='eza -la --git --icons' alias la='ls -A' alias l='ls -CF' # navigation alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' # safety nets alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # git alias gs='git status' alias gc='git commit -m' alias gp='git push' alias gl='git log --oneline --graph --decorate -20' # macOS niceties alias flushdns='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder' alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder' alias ip='curl -s https://ifconfig.me; echo' alias reload='source ~/.zshrc'

After reloading, you can type ll to get a rich directory listing with git status and icons (requires eza and a Nerd Font), ... to jump up two directories, gs to see your git status, or flushdns to clear the DNS cache in one command.

Shell Functions

Aliases can't take arguments or run multi-step logic. Functions can. Here are three that pay for themselves every week.

mkcd — make a directory and immediately enter it:

~/.zshrc
mkcd() { mkdir -p "$1" && cd "$1" }

extract — unpack any archive without memorising flags:

~/.zshrc
extract() { if [ -z "$1" ]; then echo "usage: extract <file>"; return 1; fi case "$1" in *.tar.bz2) tar xjf "$1" ;; *.tar.gz) tar xzf "$1" ;; *.tar.xz) tar xJf "$1" ;; *.tar) tar xf "$1" ;; *.tgz) tar xzf "$1" ;; *.zip) unzip "$1" ;; *.7z) 7z x "$1" ;; *.rar) unrar x "$1" ;; *) echo "unsupported: $1" ;; esac }

killport — kill whatever process is holding a port hostage (common when a dev server crashes):

~/.zshrc
killport() { lsof -ti tcp:"$1" | xargs kill -9 2>/dev/null && echo "port $1 cleared" }
Pro move: The real multiplier is combining tools with pipes. history | grep docker | tail -20 finds your last docker commands; du -sh * | sort -h | tail shows the biggest items in a directory; pbpaste | jq . pretty-prints JSON from your clipboard. Every pipe is a tiny program you built in one line.

5. Useful Scripts You Can Steal Today

Once a workflow is longer than two lines, promote it from an alias to a script. Create a ~/bin directory, add it to your PATH, drop .sh files inside, mark them executable with chmod +x, and they become first-class commands you can call by name from anywhere.

Terminal
mkdir -p ~/bin echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc source ~/.zshrc

Batch Rename Files with a Prefix

Save as ~/bin/prefix-rename, then run prefix-rename photo_ *.jpg to prefix every JPEG in the current folder with photo_.

~/bin/prefix-rename
#!/usr/bin/env bash set -euo pipefail if [ "$#" -lt 2 ]; then echo "usage: prefix-rename <prefix> <files...>"; exit 1 fi prefix="$1"; shift for f in "$@"; do dir=$(dirname "$f"); base=$(basename "$f") mv -i "$f" "$dir/${prefix}${base}" done

Timestamped Backup of a Folder

Save as ~/bin/snap. Running snap ~/Projects/raylaunchmac produces a zipped snapshot in ~/Backups with the date and time in the filename.

~/bin/snap
#!/usr/bin/env bash set -euo pipefail SRC="${1:-$PWD}" DEST="$HOME/Backups" mkdir -p "$DEST" STAMP=$(date +%Y-%m-%d_%H%M%S) NAME=$(basename "$SRC") zip -rq "$DEST/${NAME}_${STAMP}.zip" "$SRC" echo "saved $DEST/${NAME}_${STAMP}.zip"

Disk Usage Report

Save as ~/bin/diskreport. Run it with no arguments to list the ten largest items in the current directory, their sizes, and the free space on your boot volume. Perfect for a quick "what's eating my disk?" check.

~/bin/diskreport
#!/usr/bin/env bash set -euo pipefail DIR="${1:-$PWD}" echo "=== Top 10 items in $DIR ===" du -sh "$DIR"/* 2>/dev/null | sort -rh | head -n 10 echo echo "=== Free space ===" df -h / | awk 'NR==1 || NR==2'

Weather in the Terminal

Save as ~/bin/wx. Run wx for your local forecast, or wx Berlin for anywhere else. It uses the free wttr.in service — no API key required.

~/bin/wx
#!/usr/bin/env bash CITY="${1:-}" curl -s "https://wttr.in/${CITY}?F&q&n"

Make each script executable in one command and you're done:

Terminal
chmod +x ~/bin/prefix-rename ~/bin/snap ~/bin/diskreport ~/bin/wx

Those four little files replace at least a dozen Finder sessions a week. That's the point of the Terminal: small composable commands, a shell tuned to your fingers, a package manager for everything else, and a growing personal library of aliases and scripts. Spend a weekend setting it up and you'll feel the difference every working day for years. The commands and scripts in this guide are just the starting kit — your own best tools will be the ones you write to scratch your own itches.