Ultimate Mac Terminal Setup Guide

March 15, 2024 15 min read Development

1. Installing iTerm2

$ brew install --cask iterm2

Why iTerm2 over default Terminal?

Key iTerm2 Features to Enable:

Useful iTerm2 Shortcuts:

2. Package Management Setup

Install Homebrew

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

# Add to PATH (replace [username] with your username)
$ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/[username]/.zprofile
$ eval "$(/opt/homebrew/bin/brew shellenv)"

Why Homebrew?

3. Shell Framework Setup

Install Git (if not installed)

$ brew install git

Install Oh My Zsh

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

Why Oh My Zsh?

Install PowerLevel10k Theme

$ git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
# Edit ~/.zshrc:
ZSH_THEME="powerlevel10k/powerlevel10k"

Why PowerLevel10k?

Install Required Font

$ brew tap homebrew/cask-fonts
$ brew install --cask font-meslo-lg-nerd-font

Configure iTerm2 to use this font: Preferences → Profiles → Text → Font → MesloLGS NF

4. Essential Development Tools

Modern CLI Tools

# Install improved alternatives to traditional Unix tools
$ brew install eza         # Modern replacement for ls
$ brew install bat         # Better cat with syntax highlighting
$ brew install ripgrep     # Faster grep
$ brew install fd         # Better find
$ brew install fzf        # Fuzzy finder
$ brew install delta      # Better git diff
$ brew install tldr       # Simplified man pages
$ brew install jq         # JSON processor

Usage Examples:

# eza (better ls)
$ eza --icons            # List with icons
$ eza -l --git          # List with git status
$ eza --tree            # Tree view

# bat (better cat)
$ bat file.txt          # View file with syntax highlighting
$ bat -A file.txt       # Show all characters

# ripgrep (better grep)
$ rg "pattern"          # Search for pattern
$ rg -i "pattern"       # Case-insensitive search

# fd (better find)
$ fd "*.js"             # Find all JavaScript files
$ fd -H "pattern"       # Include hidden files

# fzf (fuzzy finder)
$ vim $(fzf)           # Open file in vim
$ history | fzf        # Search command history

5. Essential Zsh Plugins

Install Auto-suggestions

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

Install Syntax Highlighting

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

Install History Substring Search

$ git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search

Update ~/.zshrc plugins:

plugins=(
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-history-substring-search
    web-search
    copypath
    dirhistory
    docker
    npm
    pip
    python
    sudo
)

Plugin Explanations:

6. Productivity Enhancements

Install Additional Tools

$ brew install atuin      # Better shell history
$ brew install zoxide     # Smarter cd command
$ brew install starship   # Cross-shell prompt
$ brew install direnv     # Directory-specific environments

Configure Enhanced History with Atuin

eval "$(atuin init zsh)"

Add Useful Aliases (add to ~/.zshrc)

# Directory navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ll='eza -l --icons --git'
alias la='eza -la --icons --git'
alias lt='eza --tree --icons'

# Git shortcuts
alias gs='git status'
alias gc='git commit'
alias gp='git push'
alias gl='git pull'

# Development
alias py='python3'
alias pip='pip3'
alias serve='python3 -m http.server'

7. Final Configurations

Configure PowerLevel10k

$ p10k configure

Add to ~/.zshrc

# Better history
HISTSIZE=1000000
SAVEHIST=1000000
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS

# Better directory switching
setopt AUTO_CD

# Better completion
setopt COMPLETE_ALIASES

8. Maintenance

Keep your setup updated:

# Update Homebrew packages
$ brew update && brew upgrade

# Update Oh My Zsh
$ omz update

# Update all custom plugins
$ cd ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && git pull
$ cd ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git pull

After making any changes to ~/.zshrc, reload:

$ source ~/.zshrc

This setup provides:

Remember to:

  1. Backup your configurations
  2. Keep everything updated
  3. Customize based on your workflow
  4. Read the documentation of tools you use most
Rishav Nath Pati

Rishav Nath Pati

Software Engineer and Developer passionate about creating efficient development environments and sharing knowledge with the community.