Skip to content

Instantly share code, notes, and snippets.

@naoufalelh
Last active December 21, 2025 23:54
Show Gist options
  • Select an option

  • Save naoufalelh/7d5eac698c0113c5a5405539fb1ea94f to your computer and use it in GitHub Desktop.

Select an option

Save naoufalelh/7d5eac698c0113c5a5405539fb1ea94f to your computer and use it in GitHub Desktop.
Ultimate Zsh Setup for Engineers - Extended Prompt

Ultimate Zsh Setup for Engineers - Extended Prompt

Configure my zsh terminal with a comprehensive, high-performance setup optimized for software engineering productivity.


Part 1: Oh-My-Zsh Plugins

Install these plugins to ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/:

Plugin Repository Purpose
zsh-autosuggestions github.com/zsh-users/zsh-autosuggestions Ghost text suggestions from history
zsh-syntax-highlighting github.com/zsh-users/zsh-syntax-highlighting Real-time syntax coloring
zsh-completions github.com/zsh-users/zsh-completions 260+ additional completions
zsh-history-substring-search github.com/zsh-users/zsh-history-substring-search History search with arrow keys
zsh-you-should-use github.com/MichaelAquilina/zsh-you-should-use Reminds you of existing aliases
zsh-auto-notify github.com/MichaelAquilina/zsh-auto-notify Desktop notification when long commands finish
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
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
git clone https://github.com/MichaelAquilina/zsh-you-should-use ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/you-should-use
git clone https://github.com/MichaelAquilina/zsh-auto-notify ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/auto-notify

Part 2: CLI Tools via Homebrew

Essential Tools

brew install fzf zoxide eza bat ripgrep fd git-delta tldr jq yq htop

Advanced Tools (Optional but Recommended)

brew install lazygit gh atuin neovim tmux starship
Tool Replaces Purpose
fzf - Fuzzy finder for everything (Ctrl+R, Ctrl+T)
zoxide cd Smart directory jumping - learns your habits
eza ls Modern ls with icons, colors, git status
bat cat Syntax-highlighted file viewing
ripgrep (rg) grep 10x faster code search
fd find Fast, user-friendly file finder
git-delta diff Beautiful side-by-side git diffs
tldr man Simplified, practical command examples
jq - JSON processor for CLI
yq - YAML processor for CLI
htop top Interactive process viewer
lazygit - Terminal UI for git
gh - GitHub CLI
atuin history Magical shell history with sync
neovim vim Modern vim
tmux - Terminal multiplexer

Part 3: Configure ~/.zshrc

3.1 Performance Optimizations (Add near top of file)

# =============================================================================
# Performance Optimizations
# =============================================================================

# Efficient compinit - only regenerate completion dump once per day
autoload -Uz compinit
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
  compinit
else
  compinit -C
fi

# Lazy load nvm (saves ~500ms startup time)
lazy_load_nvm() {
  unset -f nvm node npm npx pnpm
  export NVM_DIR="$HOME/.nvm"
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
}

nvm() { lazy_load_nvm; nvm "$@"; }
node() { lazy_load_nvm; node "$@"; }
npm() { lazy_load_nvm; npm "$@"; }
npx() { lazy_load_nvm; npx "$@"; }
pnpm() { lazy_load_nvm; pnpm "$@"; }

# Lazy load rbenv (if installed)
if command -v rbenv &> /dev/null; then
  lazy_load_rbenv() {
    unset -f rbenv ruby gem
    eval "$(rbenv init -)"
  }
  rbenv() { lazy_load_rbenv; rbenv "$@"; }
  ruby() { lazy_load_rbenv; ruby "$@"; }
  gem() { lazy_load_rbenv; gem "$@"; }
fi

3.2 Plugin Configuration

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  zsh-completions
  zsh-history-substring-search
  you-should-use
  auto-notify
  docker
  kubectl
  aws
  terraform
)

# Autosuggestion settings
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#666666"

# Auto-notify settings (notify for commands taking longer than 10 seconds)
AUTO_NOTIFY_THRESHOLD=10
AUTO_NOTIFY_TITLE="Command Complete"
AUTO_NOTIFY_EXPIRE_TIME=5000

3.3 Keyboard Shortcuts for macOS

# =============================================================================
# Keyboard Shortcuts (macOS)
# =============================================================================

# Option + Arrow: Jump words
bindkey "\e[1;3D" backward-word        # ⌥←
bindkey "\e[1;3C" forward-word         # ⌥→
bindkey "^[b" backward-word
bindkey "^[f" forward-word

# Cmd + Arrow / Home/End: Jump to line start/end
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line

# Option + Backspace: Delete word
bindkey "^[^?" backward-kill-word

# Option + Delete: Delete word forward
bindkey "^[[3;3~" kill-word

# Delete key
bindkey "^[[3~" delete-char

# Ctrl shortcuts
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey "^W" backward-kill-word
bindkey "^K" kill-line
bindkey "^U" backward-kill-line

# History substring search with arrows
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
bindkey "^P" history-substring-search-up
bindkey "^N" history-substring-search-down

3.4 Tool Integrations

# =============================================================================
# Tool Integrations
# =============================================================================

# fzf - Fuzzy finder (Ctrl+R for history, Ctrl+T for files, Alt+C for cd)
source <(fzf --zsh)

# fzf configuration
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
export FZF_DEFAULT_OPTS="
  --height 40%
  --layout=reverse
  --border
  --preview 'bat --color=always --style=numbers --line-range=:500 {}'
  --preview-window=right:60%:wrap
  --bind='ctrl-/:toggle-preview'
"

# zoxide - Smart directory jumping
eval "$(zoxide init zsh)"

# atuin - Magical shell history (if installed)
if command -v atuin &> /dev/null; then
  eval "$(atuin init zsh --disable-up-arrow)"
fi

# GitHub CLI completions
if command -v gh &> /dev/null; then
  eval "$(gh completion -s zsh)"
fi

# kubectl completions (if installed)
if command -v kubectl &> /dev/null; then
  source <(kubectl completion zsh)
fi

3.5 Modern Aliases

# =============================================================================
# Modern Command Replacements
# =============================================================================

# eza - Modern ls
alias ls="eza --icons --group-directories-first"
alias ll="eza -la --icons --group-directories-first --git"
alias lt="eza --tree --level=2 --icons --git"
alias lta="eza --tree --level=3 --icons --git -a"
alias la="eza -a --icons --group-directories-first"
alias l="eza -l --icons --group-directories-first"

# bat - Modern cat
alias cat="bat --paging=never"
alias catp="bat"
alias batdiff="git diff --name-only | xargs bat --diff"

# fd - Modern find
alias find="fd"

# ripgrep enhancements
alias rg="rg --smart-case"
alias rgi="rg -i"  # case insensitive

# =============================================================================
# Git Shortcuts
# =============================================================================

alias g="git"
alias gs="git status -sb"
alias ga="git add"
alias gaa="git add --all"
alias gc="git commit"
alias gcm="git commit -m"
alias gca="git commit --amend"
alias gco="git checkout"
alias gcb="git checkout -b"
alias gb="git branch"
alias gbd="git branch -d"
alias gp="git pull"
alias gpu="git push"
alias gpuf="git push --force-with-lease"
alias gf="git fetch --all --prune"
alias gl="git log --oneline --graph --decorate -15"
alias gla="git log --oneline --graph --decorate --all"
alias gd="git diff"
alias gds="git diff --staged"
alias gst="git stash"
alias gstp="git stash pop"
alias grb="git rebase"
alias grbi="git rebase -i"
alias gm="git merge"
alias gcp="git cherry-pick"
alias lg="lazygit"

# =============================================================================
# Navigation
# =============================================================================

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~"
alias -- -="cd -"

# Quick access
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias dev="cd ~/Developer"
alias proj="cd ~/Projects"

# =============================================================================
# Development
# =============================================================================

# npm/pnpm
alias ni="npm install"
alias nr="npm run"
alias nrd="npm run dev"
alias nrb="npm run build"
alias nrt="npm run test"
alias pi="pnpm install"
alias pr="pnpm run"
alias prd="pnpm run dev"
alias prb="pnpm run build"

# Python
alias py="python3"
alias pip="pip3"
alias venv="python3 -m venv"
alias activate="source venv/bin/activate"

# Docker
alias d="docker"
alias dc="docker-compose"
alias dps="docker ps"
alias dimg="docker images"
alias dex="docker exec -it"
alias dlog="docker logs -f"
alias dprune="docker system prune -af"

# Kubernetes
alias k="kubectl"
alias kgp="kubectl get pods"
alias kgs="kubectl get services"
alias kgd="kubectl get deployments"
alias klog="kubectl logs -f"
alias kex="kubectl exec -it"

# =============================================================================
# Utility Functions
# =============================================================================

# Create directory and cd into it
mkcd() { mkdir -p "$@" && cd "$@"; }

# Extract any archive
extract() {
  if [ -f "$1" ]; then
    case "$1" in
      *.tar.bz2)   tar xjf "$1"   ;;
      *.tar.gz)    tar xzf "$1"   ;;
      *.bz2)       bunzip2 "$1"   ;;
      *.rar)       unrar x "$1"   ;;
      *.gz)        gunzip "$1"    ;;
      *.tar)       tar xf "$1"    ;;
      *.tbz2)      tar xjf "$1"   ;;
      *.tgz)       tar xzf "$1"   ;;
      *.zip)       unzip "$1"     ;;
      *.Z)         uncompress "$1";;
      *.7z)        7z x "$1"      ;;
      *)           echo "'$1' cannot be extracted" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}

# Quick HTTP server
serve() { python3 -m http.server ${1:-8000}; }

# Get public IP
myip() { curl -s ifconfig.me; echo; }

# Weather
weather() { curl -s "wttr.in/${1:-}"; }

# Preview files with fzf + bat
preview() { fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'; }

# Search and open in editor
se() { 
  local file
  file=$(fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}')
  [ -n "$file" ] && ${EDITOR:-code} "$file"
}

# Git branch selector with fzf
fbr() {
  local branch
  branch=$(git branch --all | fzf --height 40% --reverse | sed 's/^..//' | sed 's/remotes\/origin\///')
  [ -n "$branch" ] && git checkout "$branch"
}

# Kill process with fzf
fkill() {
  local pid
  pid=$(ps -ef | fzf --height 40% --reverse | awk '{print $2}')
  [ -n "$pid" ] && kill -9 "$pid"
}

# =============================================================================
# Quick Config Access
# =============================================================================

alias zshconfig="$EDITOR ~/.zshrc"
alias reload="source ~/.zshrc && echo 'Zsh config reloaded!'"
alias path='echo -e ${PATH//:/\\n}'

# Profiling (uncomment to debug slow startup)
# zmodload zsh/zprof
# Add this at end of .zshrc: zprof

Part 4: Git Configuration for Delta

# Beautiful diffs with delta
git config --global core.pager delta
git config --global interactive.diffFilter "delta --color-only"
git config --global delta.navigate true
git config --global delta.side-by-side true
git config --global delta.line-numbers true
git config --global delta.syntax-theme "Dracula"

# Useful git defaults
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global fetch.prune true
git config --global diff.colorMoved zebra
git config --global merge.conflictStyle zdiff3

Part 5: Optional Enhancements

Atuin Setup (Magical Shell History)

brew install atuin
atuin init zsh >> ~/.zshrc
atuin import auto  # Import existing history

Starship Prompt (Alternative to Powerlevel10k)

brew install starship
echo 'eval "$(starship init zsh)"' >> ~/.zshrc

iTerm2 Configuration

  • Go to: iTerm2 → Settings → Profiles → Keys → Key Mappings
  • Click: Presets → Natural Text Editing
  • This enables native macOS text navigation shortcuts

Part 6: Verification & Testing

Test configuration loads without errors:

zsh -c 'source ~/.zshrc && echo "SUCCESS: Config loaded!"'

Profile startup time (should be < 200ms):

time zsh -i -c exit

If startup is slow, enable profiling:

Add at top of ~/.zshrc: zmodload zsh/zprof Add at bottom of ~/.zshrc: zprof


Expected Results

After setup, the user should have:

Visual Enhancements

  • ✅ Syntax highlighting while typing (green=valid, red=error)
  • ✅ Ghost text autosuggestions from history
  • ✅ Beautiful colorized output for ls, cat, git diff
  • ✅ Icons in file listings

Productivity Features

  • Ctrl+R - Fuzzy search command history
  • Ctrl+T - Fuzzy find files
  • z <folder> - Smart jump to any directory
  • ✅ Arrow up/down - Search history by what you've typed
  • ✅ Tab completion for 260+ commands
  • ✅ Alias reminders ("you should use" plugin)
  • ✅ Desktop notifications for long-running commands

Keyboard Navigation

  • ✅ Option+Arrow - Jump words
  • ✅ Cmd+Arrow / Home/End - Jump to line start/end
  • ✅ Option+Backspace - Delete word
  • ✅ Option+Delete - Delete word forward

Developer Tools

  • lg - Lazygit for visual git
  • rg - Ultra-fast code search
  • fd - Fast file finder
  • tldr - Simplified command examples
  • ✅ Beautiful side-by-side git diffs

Performance

  • ✅ Startup time < 200ms (lazy loading enabled)
  • ✅ Completion cache regenerated only once per day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment